Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

emcc output does not work in Node.js 18. #16915

Closed
mizar opened this issue May 8, 2022 · 5 comments
Closed

emcc output does not work in Node.js 18. #16915

mizar opened this issue May 8, 2022 · 5 comments

Comments

@mizar
Copy link

mizar commented May 8, 2022

Preparatory operations

docker pull emscripten/emsdk:latest;
docker pull node:lts-alpine;
docker pull node:alpine;

Version of emscripten/emsdk:

input command:

docker run --rm emscripten/emsdk:latest emcc -v;

output:

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

Failing command line in full:

Suppose the following files are placed in the current directory:

./hello.c:

#include <stdio.h>
int main(int argc, char** argv){
  printf("Hello, world!\n");
  return 0;
}

compile

input command:

docker run --rm -v ${PWD}:/src emscripten/emsdk:latest emcc hello.c -o hello.js;

run on node:lts-alpine (success)

input command:

docker run --rm -v ${PWD}:/src node:lts-alpine node /src/hello.js;

output:

Hello, world!

run on node:alpine (failed)

input command:

docker run --rm -v ${PWD}:/src node:alpine node /src/hello.js;

output:

(node:1) 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)
/src/hello.js:146
      throw ex;
      ^

TypeError: Failed to parse URL from /src/hello.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> (/src/hello.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 (/src/hello.js:1670:14)
      at createWasm (/src/hello.js:1707:3)
      at Object.<anonymous> (/src/hello.js:1914:11) {
    input: '/src/hello.wasm',
    code: 'ERR_INVALID_URL'
  }
}

Node.js v18.1.0

run on node:alpine with --no-experimental-fetch (success)

input command:

docker run --rm -v ${PWD}:/src node:alpine node --no-experimental-fetch /src/hello.js;

output:

Hello, world!
@mizar
Copy link
Author

mizar commented May 8, 2022

@mizar
Copy link
Author

mizar commented May 8, 2022

input command:

docker run --rm -v ${PWD}:/src node:alpine sh -c "NODE_OPTIONS='--no-experimental-fetch' node /src/hello.js";

output:

Hello, world!

@mizar
Copy link
Author

mizar commented May 9, 2022

@svenpilz
Copy link

Same here, --no-experimental-fetch helps. Thanks @mizar.

@kripken
Copy link
Member

kripken commented May 27, 2022

This should be fixed by #16917

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants