ton-community / ton-contract-executor

The TON Contract Executor allows you to write, debug, and fully test your contracts before launching them to the TON blockchain.
64 stars 11 forks source link

Error on Node.js 18 #5

Open NoelJacob opened 2 years ago

NoelJacob commented 2 years ago
(node:15366) 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/event_target:908
  process.nextTick(() => { throw err; });
                           ^
TypeError [Error]: Failed to parse URL from /home/noel/Desktop/conex/node_modules/.pnpm/ton-contract-executor@0.5.0_ton@11.6.1/node_modules/ton-contract-executor/dist/vm-exec/vm-exec.wasm
    at new Request (node:internal/deps/undici/undici:4813:19)
    at Agent.fetch2 (node:internal/deps/undici/undici:5539:29)
    ... 4 lines matching cause stack trace ...
    at /home/noel/Desktop/conex/node_modules/.pnpm/ton-contract-executor@0.5.0_ton@11.6.1/node_modules/ton-contract-executor/dist/vm-exec/vm-exec.js:9:38689
    at getInstance (/home/noel/Desktop/conex/node_modules/.pnpm/ton-contract-executor@0.5.0_ton@11.6.1/node_modules/ton-contract-executor/dist/vm-exec/vmExec.js:16:22)
    at vm_exec (/home/noel/Desktop/conex/node_modules/.pnpm/ton-contract-executor@0.5.0_ton@11.6.1/node_modules/ton-contract-executor/dist/vm-exec/vmExec.js:22:28)
    at runTVM (/home/noel/Desktop/conex/node_modules/.pnpm/ton-contract-executor@0.5.0_ton@11.6.1/node_modules/ton-contract-executor/dist/executor/executor.js:58:39)
Emitted 'error' event on Worker instance at:
    at [kOnErrorMessage] (node:internal/worker:289:10)
    at [kOnMessage] (node:internal/worker:300:37)
    at MessagePort.<anonymous> (node:internal/worker:201:57)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:639:20)
    at exports.emitMessage (node:internal/per_context/messageport:23:28) {
  [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:4811:25)
      at Agent.fetch2 (node:internal/deps/undici/undici:5539:29)
      at Object.fetch (node:internal/deps/undici/undici:6370:20)
      at fetch (node:internal/bootstrap/pre_execution:196:25)
      at instantiateAsync (/home/noel/Desktop/conex/node_modules/.pnpm/ton-contract-executor@0.5.0_ton@11.6.1/node_modules/ton-contract-executor/dist/vm-exec/vm-exec.js:9:10542)
      at createWasm (/home/noel/Desktop/conex/node_modules/.pnpm/ton-contract-executor@0.5.0_ton@11.6.1/node_modules/ton-contract-executor/dist/vm-exec/vm-exec.js:9:11152)
      at /home/noel/Desktop/conex/node_modules/.pnpm/ton-contract-executor@0.5.0_ton@11.6.1/node_modules/ton-contract-executor/dist/vm-exec/vm-exec.js:9:38689
}

Node.js v18.2.0

I ran the examples and this is the result. My system is arch linux.

NoelJacob commented 2 years ago

This is an bug https://github.com/emscripten-core/emscripten/issues/16913, caused by Node adding WebAssembly.instantiateStreaming in version 18. I'm sure either emscripten or node will come up with a real solution to this at some point (there's a PR https://github.com/emscripten-core/emscripten/pull/16917), but in the mean time you can work around this by invoking node with --no-experimental-fetch.

arterialist commented 1 year ago

I have encountered exact same issue on Node v18.7.0. Downdrading to v16.18.0 solves the issue.

manylov commented 1 year ago

It is very frustrating, at least it would be great if some error message will be added for users who want to compile it on node 18. Is it possible to fix somehow?

NoelJacob commented 1 year ago

@manylov @arterialist do node --no-experimental-fetch script.js