sql.js
sql.js copied to clipboard
"fetch" api included in NodeJS v18 brokes sql.js
NodeJS 18 includes experiential support for the "fetch" api. This is causing sql.js not to work properly after Node v18. Because it checks if there is an global "fetch" funcion exists. If so it tries to fetch the wasm file.
sql-wasm.js
.... "function"!=typeof fetch?c(b):fetch(P,{credentials:"same-origin"}) .....
This check is invalid for NodeJS v18.
This is a good catch, but this is an emscripten issue, isn't it ? All we can do is update to a more recent emscripten when they fix the bug, right ?
I'm having a perhaps related strange error:
Error: Aborted(RuntimeError: Aborted(Error: ENOENT: no such file or directory, open 'http:/localhost:8000/sql-wasm.wasm'). Build with -sASSERTIONS for more info.). Build with -sASSERTIONS for more info.
❯ E node_modules/sql.js/dist/sql-wasm.js:101:154
❯ node_modules/sql.js/dist/sql-wasm.js:158:425
Trying to serve a custom sql-wasm.wasm
file for myself. Getting these errors suddenly :grimacing: At one point I did npm i
and it said "changed 1 packaged" and then things started working again? But then when I reinstalled all my packages, on node version 18.8.0, it gave me this error. I've triple checked the url I'm passing in, and it is (correctly) http://localhost:8000/sql-wasm.wasm
(with both slashes, not one). :shrug:
EDIT: using sql.js version 1.7.0 fixed this for me. Also, staying with node version 18 rather than 16.
Can confirm this is fixed. Works for me on sql.js 1.8.0 and Node 19.2.0