jepiqueau/vue-typeorm-app

main.ts:80 wasm streaming compile failed: TypeError: Failed to execute 'compile' on 'WebAssembly': Incorrect response MIME type. Expected 'application/wasm'. await in createDatabaseConnection (async)

lthamm opened this issue · 3 comments

I just cant seem to get this setup running - neither when I clone your app nor when I set it up from scratch with the latest version created from the ionic cli.

The error i consistently stumble upon is at main.ts:80 when running await connection.initialize();:
main.ts:80 wasm streaming compile failed: TypeError: Failed to execute 'compile' on 'WebAssembly': Incorrect response MIME type. Expected 'application/wasm'. await in createDatabaseConnection (async

Full error:

[Error] wasm streaming compile failed: TypeError: Unexpected response MIME type. Expected 'application/wasm'
	error
	(anonyme Funktion) (jeep-sqlite.entry-EQZIE3Q5.js:2619)
[Error] falling back to ArrayBuffer instantiation
	error
	(anonyme Funktion) (jeep-sqlite.entry-EQZIE3Q5.js:2620)
[Error] failed to asynchronously prepare wasm: CompileError: WebAssembly.Module doesn't parse at byte 0: module doesn't start with '\0asm'
	error
	(anonyme Funktion) (jeep-sqlite.entry-EQZIE3Q5.js:2612)
[Error] Aborted(CompileError: WebAssembly.Module doesn't parse at byte 0: module doesn't start with '\0asm')
	error
	C (jeep-sqlite.entry-EQZIE3Q5.js:2578)
	(anonyme Funktion) (jeep-sqlite.entry-EQZIE3Q5.js:2613)
[Error] Unhandled Promise Rejection: Error: CompileError: WebAssembly.Module doesn't parse at byte 0: module doesn't start with '\0asm'
	(anonyme Funktion) (jeep-sqlite.entry-EQZIE3Q5.js:2023)
[Error] Unhandled Promise Rejection: RuntimeError: Aborted(CompileError: WebAssembly.Module doesn't parse at byte 0: module doesn't start with '\0asm'). Build with -sASSERTIONS for more info.

http://localhost:8100/tabs/tab1
So it seems like the way ionic server the app, the MIME type is not correctly recognized, but I have no clue how I would fix this.
For reference I am on node 20 and ionic toolchain builds the app with vite.

Ok dont be stupid, actually copy the file to public/assets/sql-wasm.wasm and not the js file public/assets/sql-wasm.js.

@lthamm make sure that you have copied on the public/assets folder the sql-wasm.wasm from the node-modules/sql.js/dist

Thanks for getting back so fast! I noticed a few minutes before you replied and closed the issue. Sorry for wasting everyones time but maybe someone else can learn from that mistake. If you take that into account, it works very well.