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

rhino3dm.js incompatible with Node v18. I keep getting error ERR_INVALID_URL #492

Closed
dgrcode opened this issue Jan 11, 2023 · 15 comments
Closed
Labels
Milestone

Comments

@dgrcode
Copy link

dgrcode commented Jan 11, 2023

I was getting this issue with 0.14.0. After upgrading to 7.15.0 I keep getting the same error.

TypeError: Failed to parse URL from {project path}/node_modules/rhino3dm/rhino3dm.wasm
    at Object.fetch (node:internal/deps/undici/undici:11118:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  [cause]: TypeError [ERR_INVALID_URL]: Invalid URL
      at new NodeError (node:internal/errors:393:5)
      at URL.onParseError (node:internal/url:565:9)
      at new URL (node:internal/url:645:5)
      at new Request (node:internal/deps/undici/undici:9472:25)
      at Agent.fetch2 (node:internal/deps/undici/undici:10291:25)
      at Object.fetch (node:internal/deps/undici/undici:11116:28)
      at fetch (node:internal/process/pre_execution:216:25)
      at instantiateAsync ({project path}/node_modules/rhino3dm/rhino3dm.js:9:16039)
      at createWasm ({project path}/node_modules/rhino3dm/rhino3dm.js:9:16646)
      at {project path}/node_modules/rhino3dm/rhino3dm.js:9:131229 {
    input: '{project path}/node_modules/rhino3dm/rhino3dm.wasm',
    code: 'ERR_INVALID_URL'
  }
}

I'm not sure what's going on, because the file at {project path}/node_modules/rhino3dm/rhino3dm.wasm is there. I can do cat {project path}/node_modules/rhino3dm/rhino3dm.wasm and see a bunch of binary output.

I think I might have updated node to v18.12.1 before I started seeing this issue. Could this be a node 18 compatibility issue?

I do get this warning when starting the server:

(node:71881) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time
@dgrcode
Copy link
Author

dgrcode commented Jan 11, 2023

I can confirm I don't get this issue with node v16.19.0. We'd have to confirm this is a node 18 incompatibility issue. This would be a problem given node releases.

From node's release schedule (link), here's the versions lifetime
image

v16 entered maintenance status about 3 months ago, on 2022-10-18. End of life will be 2023-09-11.

@dgrcode
Copy link
Author

dgrcode commented Jan 11, 2023

cross-posted to McNeel YouTrack Application as per CONTRIBUTING.md.

Link: https://mcneel.myjetbrains.com/youtrack/issue/BO-3497/rhino3dm.js-with-Node-18-throws-error-ERRINVALIDURL

@sbaer
Copy link
Member

sbaer commented Jan 14, 2023

What does the code that loads rhino3dm in your node server look like?

@dgrcode
Copy link
Author

dgrcode commented Jan 16, 2023

This is the code that loads rhino3dm

const rhino3dm = require('rhino3dm')

console.log('rhino3dm: initializing')
/**
 * @type Promise<rhino3dm.RhinoModule>
 */
const rhinoPromise = rhino3dm()
  .then((rhino) => {
    console.log('rhino3dm: loaded')
    return rhino
  })
  .catch((err) => {
    console.log('rhino3dm: error', err)
  })

module.exports = rhinoPromise

Then, I use it like this:

const rhinoPromise = require('./server/services/rhino3dm')

const rhino = await rhinoPromise

But I'm confident that's not the issue, because that exact code works with node v16. It has only stopped working when I updated node to v18

@dgrcode dgrcode changed the title rhino3dm.js keep getting error ERR_INVALID_URL rhino3dm.js incompatible with Node v18. I keep getting error ERR_INVALID_URL Jan 24, 2023
@dgrcode
Copy link
Author

dgrcode commented Jan 24, 2023

Hi @sbaer any news on this? Can we confirm rhino3dm.js is not compatible with Node v18?

@fraguada
Copy link
Member

fraguada commented Jan 24, 2023

@dgrcode Depending on the version of emscriptem, web assembly compiled code is not compatible with Node v18.1.0 and above. See: emscripten-core/emscripten#16913

Seems there was a patch applied. We need to see how to build rhino3dm with an updated version of emscripten to get the benefit of the patch. emscripten-core/emscripten#16917

In the meantime you can run your scripts in node.js 18.1.0 and above like so:
node --no-experimental-fetch index.js

Running in 16.15.0 (at least, haven't checked below) - 18.0.0 works as you'd expect.

@dgrcode
Copy link
Author

dgrcode commented Jan 24, 2023

Awesome, thanks for the details and workaround 🙌

@fraguada fraguada added the js label Feb 7, 2023
@fraguada
Copy link
Member

fraguada commented Feb 24, 2023

update: by updating our build tools, this issue is no longer present. We are getting ready to release an update. If you want to test, you can do so my using a recent build of js: https://github.com/mcneel/rhino3dm/suites/11184627947/artifacts/571581718

@fraguada fraguada added this to the 8.0.0 milestone Feb 27, 2023
@dgrcode
Copy link
Author

dgrcode commented Feb 28, 2023

I can confirm the files in the link work as expected. Thanks for fixing this one. Is there an estimate update release date?

@fraguada
Copy link
Member

Thanks for testing!
We have most everything in place for a release except for testing. Hopefully we can wrap it up in a week or so.

@fraguada
Copy link
Member

@dgrcode Just published rhino3dm.js 8.0.0. https://www.npmjs.com/package/rhino3dm

@dgrcode
Copy link
Author

dgrcode commented Mar 14, 2023

Thanks for the heads up! I just upgraded to 8.0.0 and it's working great using node v18

@fraguada
Copy link
Member

Thanks for reporting @dgrcode!

@dgrcode
Copy link
Author

dgrcode commented Apr 21, 2023

EDIT: Just opened a new issue #521 to track this

Quick question. I just created a 3dm file with the rhino3dm.js library, and it gave me an error when trying to open it with Rhino. It said something like the file had been created with Rhino 8 and it couldn't be opened with Rhino 7. I haven't seen any Rhino 8 available yet.

Is that expected?

@fraguada
Copy link
Member

answered in #521

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

No branches or pull requests

3 participants