Skip to content

Node.js implemented WebAssembly.instantiateStreaming in v18.1.0 #16913

@aduh95

Description

@aduh95

Version of emscripten/emsdk:
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.10 (c3fe57a)
clang version 15.0.0 (https://github.com/llvm/llvm-project 8bc29d14273b05b05d5a56e34c07948dc2c770d3)
Target: wasm32-unknown-emscripten
Thread model: posix

Failing command line in full:

$ emcc -s ENVIRONMENT=node hello_world.c
$ node a.out.js 
(node:50298) 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)
…/a.out.js:146
      throw ex;
      ^

TypeError: Failed to parse URL from …/a.out.wasm
    at new Request (node:internal/deps/undici/undici:4816:19)
    at Agent2.fetch2 (node:internal/deps/undici/undici:5544:29)
    ... 4 lines matching cause stack trace ...
    at Object.<anonymous> (…/a.out.js:1914:11)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32) {
  [cause]: TypeError [ERR_INVALID_URL]: Invalid URL
      at new NodeError (node:internal/errors:377:5)
      at URL.onParseError (node:internal/url:563:9)
      at new URL (node:internal/url:643:5)
      at new Request (node:internal/deps/undici/undici:4814:25)
      at Agent2.fetch2 (node:internal/deps/undici/undici:5544:29)
      at Object.fetch (node:internal/deps/undici/undici:6372:20)
      at fetch (node:internal/bootstrap/pre_execution:199:25)
      at instantiateAsync (…/a.out.js:1670:14)
      at createWasm (…/a.out.js:1707:3)
      at Object.<anonymous> (…/a.out.js:1914:11) {
    input: '…/a.out.wasm',
    code: 'ERR_INVALID_URL'
  }
}

Node.js v18.1.0

Note that disabling fetch does the trick:

$ node --no-experimental-fetch a.out.js 
hello, world!

Ideally instantiateStreaming should be called only on HTTP URIs.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions