node-fetch icon indicating copy to clipboard operation
node-fetch copied to clipboard

fetch API breaks existing module and adding --no-experimental-fetch fixes the problem

Open tomfinegan opened this issue 2 years ago • 2 comments

Repro steps:

  1. Install node 18
  2. npm install draco3d
  3. change dir to draco3d install directory
  4. node draco_nodejs_example.js

Above fails:

$ node draco_nodejs_example.js
(node:16258) 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:4813
            throw new TypeError("Failed to parse URL from " + input, { cause: err });
                  ^

TypeError: Failed to parse URL from /Users/tomfinegan/tmp/node_modules/draco3d/draco_decoder.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 Object.createDecoderModule (/Users/tomfinegan/tmp/node_modules/draco3d/draco_decoder_nodejs.js:39:247)
    at Object.<anonymous> (/Users/tomfinegan/tmp/node_modules/draco3d/draco_nodejs_example.js:29:9)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1159:10) {
  [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 /Users/tomfinegan/tmp/node_modules/draco3d/draco_decoder_nodejs.js:39:1
      at /Users/tomfinegan/tmp/node_modules/draco3d/draco_decoder_nodejs.js:39:224
      at Object.createDecoderModule (/Users/tomfinegan/tmp/node_modules/draco3d/draco_decoder_nodejs.js:39:247) {
    input: '/Users/tomfinegan/tmp/node_modules/draco3d/draco_decoder.wasm',
    code: 'ERR_INVALID_URL'
  }
}

Node.js v18.2.0

Adding --no-experimental-fetch fixes the issue:

$ node --no-experimental-fetch draco_nodejs_example.js
Decoder Module Initialized!
Encoder Module Initialized!
Decoding file of size 96018 ..
Number of faces 69451
Number of vertices 34834
Adding POSITION attribute
Encoding...
Encoded size is 50135
The file was saved!

Draco is tracking this here: https://github.com/google/draco/issues/888 One of our users encountered it and reported it here: https://github.com/CesiumGS/gltf-pipeline/issues/613

tomfinegan avatar May 24 '22 17:05 tomfinegan

I've been having the same issue, this worked for me as well. Thanks!

tleecode avatar Oct 21 '22 05:10 tleecode

Thanks! This saved my day!

gastonfournier avatar Apr 18 '23 07:04 gastonfournier