sql-js / sql-js/sql.js

Error when installed from NPM and used with a React App

Offen
#282 4 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

Installing the library from NPM and running it breaks with:

Uncaught (in promise) Error: CompileError: WebAssembly.compile(): expected magic word 00 61 73 6d, found 3c 21 44 4f @+0
    at Object.Module.onAbort (sql-wasm.js:34)
    at B (sql-wasm.js:3614)
    at sql-wasm.js:1024

Here's the minimal code that consistently produces the error above:

import initSqlJs from 'sql.js';

initSqlJs().then(function(SQL){

  // Create a database
  var db = new SQL.Database();
});

And here's a CodeSandbox that demonstrates the problem.

Using the code from the CDN works fine but it exposes a global window.SQL which is harder to mock during testing (among other things) so I'd prefer using the NPM library.

Do you have any pointers on what this magic number business is?

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 with the npm-built sql-wasm.js referenced in the stack trace and compare its loading behavior with the working CDN version. Reproduce the minimal initSqlJs example in the linked CodeSandbox or a React app; done means the npm package loads valid WebAssembly and creates a SQL.Database without the compile error.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, wasm
Bereich
database, web-dev
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
30/100

Neue Issues direkt in Ihr Postfach

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