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

panic trying to load Vite.createServer() #426

Open
wasabii opened this issue Feb 11, 2025 · 2 comments
Open

panic trying to load Vite.createServer() #426

wasabii opened this issue Feb 11, 2025 · 2 comments

Comments

@wasabii
Copy link
Contributor

wasabii commented Feb 11, 2025

Getting a panic trying to use RunAsync to import and invoke a JS method from a C# app using EmbeddingThreadRuntime/etc.

This is using the main branch as of today. The libnode itself was built by me.

thread '<unnamed>' panicked at C:\Users\runneradmin/.cargo\registry\src\index.crates.io-6f17d22bba15001f\napi-sys-2.4.0\src\functions.rs:7:3:
Node-API symbol has not been loaded
stack backtrace:
   0:     0x7ffcfa4265ec - napi_register_module_v1
   1:     0x7ffcfa3b9d9a - <unknown>
   2:     0x7ffcfa41d587 - napi_register_module_v1
   3:     0x7ffcfa427864 - napi_register_module_v1
   4:     0x7ffcfa427d71 - napi_register_module_v1
   5:     0x7ffcfa427912 - napi_register_module_v1
   6:     0x7ffcfa42789f - napi_register_module_v1
   7:     0x7ffcfa42788e - napi_register_module_v1
   8:     0x7ffcfa5fc091 - napi_register_module_v1
   9:     0x7ffcfa3d363b - napi_register_module_v1
  10:     0x7ffcfa3d35d7 - napi_register_module_v1

The problem is specifically limited to Vite.createServer right now. I can't figure out what it does internally to cause this. But my suspicion, thought I can't yet prove it, is that it loads a module which loads a module which loads a native module, which fails. Since I don't understand what's happening enough I haven't been able to create a reproduction.

Some enlightenment about what to look at may be useful. Is this a crash on the node side, because it's doing something truly awful, or is it some interaction with NodeAPI?

@wasabii
Copy link
Contributor Author

wasabii commented Feb 12, 2025

Okay. So I at least know the parts involved now. It's the @rollup/rollup-win32-x64-msvc package. Which is a native module built in Rust using node-sys/2.4.0 from https://github.com/napi-rs/napi-rs/blob/main/crates/napi/src/bindgen_runtime/js_values/function.rs

panics in libnode for some reason

@wasabii
Copy link
Contributor Author

wasabii commented Feb 12, 2025

So I think the problem MIGHT be that the node-rs project expects the NAPI functions to be in the program module at runtime. But they're not. They're in libnode.dll. Similar problems exist with people trying to use nwjs, Electron, etc. And various approaches have been attempted. So my guess here is prrrrobably anything using rust-rs is broke on libnode presently.

napi-rs/napi-rs#1480

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

1 participant