Open
Description
Steps to reproduce:
$ docker run -it --rm node:18 /bin/bash
# mkdir test && cd test
# npm init -y && npm i wasm-lz4
# node -e 'require("wasm-lz4")'
Result:
(node:31) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
node:internal/deps/undici/undici:11118
Error.captureStackTrace(err, this);
^
TypeError: Failed to parse URL from /test/node_modules/wasm-lz4/wasm-lz4.wasm
at Object.fetch (node:internal/deps/undici/undici:11118:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
[cause]: TypeError [ERR_INVALID_URL]: Invalid URL
at new NodeError (node:internal/errors:393:5)
at URL.onParseError (node:internal/url:565:9)
at new URL (node:internal/url:645:5)
at new Request (node:internal/deps/undici/undici:9472:25)
at Agent.fetch2 (node:internal/deps/undici/undici:10291:25)
at Object.fetch (node:internal/deps/undici/undici:11116:28)
at fetch (node:internal/process/pre_execution:216:25)
at instantiateAsync (/test/node_modules/wasm-lz4/wasm-lz4.js:9:8977)
at createWasm (/test/node_modules/wasm-lz4/wasm-lz4.js:9:9587)
at /test/node_modules/wasm-lz4/wasm-lz4.js:9:10837 {
input: '/test/node_modules/wasm-lz4/wasm-lz4.wasm',
code: 'ERR_INVALID_URL'
}
}
Node.js v18.12.1
The same error does not occur when using Node 16.
This appears to be caused by emscripten-core/emscripten#16915, which was fixed in emscripten-core/emscripten#16917 (available in emscripten 3.1.13 and later), so it could likely be fixed by upgrading emscripten.
See also: foxglove/wasm-bz2#4