CesiumGS / gltf-pipeline

Content pipeline tools for optimizing glTF assets. :globe_with_meridians:

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Draco compression tries to use the fetch api to load the wasm blob off the filesystem and fails with `ERR_INVALID_URL`

expenses opened this issue · comments

Full error:

(node:4270) 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)
TypeError: Failed to parse URL from /home/ashley/node_modules/draco3d/draco_encoder.wasm
    at new Request (node:internal/deps/undici/undici:4816:19)
    at Agent2.fetch2 (node:internal/deps/undici/undici:5544:29)
    ... 10 lines matching cause stack trace ...
    at Object.tryCatcher (/home/ashley/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/ashley/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/home/ashley/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/home/ashley/node_modules/bluebird/js/release/promise.js:649: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: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 /home/ashley/node_modules/draco3d/draco_encoder_nodejs.js:36:498
      at /home/ashley/node_modules/draco3d/draco_encoder_nodejs.js:37:214
      at Object.createEncoderModule (/home/ashley/node_modules/draco3d/draco_encoder_nodejs.js:37:237)
      at compressDracoMeshes (/home/ashley/node_modules/gltf-pipeline/lib/compressDracoMeshes.js:54:52)
      at /home/ashley/node_modules/gltf-pipeline/lib/processGltf.js:67:12
      at tryCatcher (/home/ashley/node_modules/bluebird/js/release/util.js:16:23)
      at Object.gotValue (/home/ashley/node_modules/bluebird/js/release/reduce.js:166:18)
      at Object.gotAccum (/home/ashley/node_modules/bluebird/js/release/reduce.js:155:25)
      at Object.tryCatcher (/home/ashley/node_modules/bluebird/js/release/util.js:16:23) {
    input: '/home/ashley/node_modules/draco3d/draco_encoder.wasm',
    code: 'ERR_INVALID_URL'
  }
}

Reproducible in script:

const draco3d = require("draco3d");
let decoderModulePromise = Promise.resolve(draco3d.createDecoderModule({}));
console.log({decoderModulePromise})
 ~ node /Users/danvas/.nvm/versions/node/v18.1.0/lib/node_modules/gltf-pipeline/lib/debugg.js
{ decoderModulePromise: Promise { <pending> } }
(node:81439) 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:4816
            throw new TypeError("Failed to parse URL from " + input, { cause: err });
                  ^

TypeError: Failed to parse URL from /Users/danvas/.nvm/versions/node/v18.1.0/lib/node_modules/gltf-pipeline/node_modules/draco3d/draco_decoder.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.createDecoderModule (/Users/danvas/.nvm/versions/node/v18.1.0/lib/node_modules/gltf-pipeline/node_modules/draco3d/draco_decoder_nodejs.js:39:247)
    at Object.<anonymous> (/Users/danvas/.nvm/versions/node/v18.1.0/lib/node_modules/gltf-pipeline/lib/debugg.js:4:52)
    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: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 /Users/danvas/.nvm/versions/node/v18.1.0/lib/node_modules/gltf-pipeline/node_modules/draco3d/draco_decoder_nodejs.js:39:1
      at /Users/danvas/.nvm/versions/node/v18.1.0/lib/node_modules/gltf-pipeline/node_modules/draco3d/draco_decoder_nodejs.js:39:224
      at Object.createDecoderModule (/Users/danvas/.nvm/versions/node/v18.1.0/lib/node_modules/gltf-pipeline/node_modules/draco3d/draco_decoder_nodejs.js:39:247) {
    input: '/Users/danvas/.nvm/versions/node/v18.1.0/lib/node_modules/gltf-pipeline/node_modules/draco3d/draco_decoder.wasm',
    code: 'ERR_INVALID_URL'
  }
}

Node.js v18.1.0

@expenses - Were you able to find a quick workaround? (For example, hardcode the path)

No, I didn't look very hard into this. An easy workaround seems like it should be possible though.

Seems to only happen in Node 18. Node 16 works fine. I tested draco 1.5.2 for both.

Assuming this problem isn't caused by gltf-pipeline in some way, could you submit to bug report to the draco repo?

Seems to only happen in Node 18. Node 16 works fine. I tested draco 1.5.2 for both.

Assuming this problem isn't caused by gltf-pipeline in some way, could you submit to bug report to the draco repo?

Done: google/draco#888

Can you try running with "--no-experimental-fetch" command line flag?

We think this has to deal with emscripten-core/emscripten#16913

Can you try running with "--no-experimental-fetch" command line flag?

We think this has to deal with emscripten-core/emscripten#16913

I can confirm that this fixes the problem for me.