sql-js / sql-js/sql.js

sql-wasm.wasm file is not getting loaded correctly when invoked as a web worker

Offen
#521 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
JavaScript
Sterne
13.7k
Forks
1.1k
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

Overview

The responding sql-wasm.wasm file requested by worker.sql-wasm.js doesn't get served correctly and thus leads to a 404 error. I am not sure if that is a bug which is native to next.js though and thus opened an issue there as well. I spend the last two to three days looking into lots of similar issues on github, but none seems to be a viable solution.

Description

I try to invoke a web-worker in one of my pages like this:

/** Add your relevant code here for the issue to reproduce */
export default function Home() {
  const createDb = () => {
    const worker = new Worker(
      new URL('../public/assets/worker.sql-wasm.js', import.meta.url)
    );
    worker.onerror = (e) => console.log('Worker error: ', e);
  };
  return (
    <>
      <h1>Test</h1>
      <br />
      <button
        onClick={() => {
          createDb();
        }}
      >
        Create DB
      </button>
    </>
  );
}

(Please see my reproduction of the problem at Stackblitz)

When doing so I get served a 404 error as the sql-wasm.wasm file can't be find inside the build directory i.e. http://localhost:3000/_next/static/chunks/sql-wasm.wasm.

Question

Is this error due to the nature of the locateFile() function of emscripten or due to a mistake in how I configured the corresponding next.config.js file?

/** @type {import("next").NextConfig} */
const config = {
  reactStrictMode: true,
  webpack: (
    config,
    { buildId, dev, isServer, defaultLoaders, nextRuntime, webpack }
  ) => {
    if (!isServer) {
      config.resolve.fallback.fs = false;
    }
    return config;
  },
};

module.exports = config;

ANY help is much appreciated!

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Start by running the StackBlitz reproduction and inspect worker.sql-wasm.js, next.config.js, and the reported Next.js issue. Trace the request for sql-wasm.wasm when the web worker starts; done means the worker loads the WASM file without the reported 404.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, next.js, sqlite, wasm
Bereich
database, frontend
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.