Closed pepsi closed 4 years ago
Neon is specifically for building modules against node.js and not v8. Neon includes Node header files which in turn include v8 header files. It's likely that these symbol definitions are conflicting.
I am closing this issue because it appears outside the scope of Neon. Please let me know if that's not the case!
I am building against node.js, Im just testing out a "serverless" type thing for discord bots platform, and for that I need to run some js code. I've found that the easiest way to do that, is with a clean, v8 javscript sandbox. The plan is to have a nodejs script, that calls into a rust script that spawns a v8 instance. If you need further clarification about anything along the way, Ill be glad to explain it :)
I'm not sure if node would support other instances of v8
in the process. There are some globals managed in the threads.
If it is supported, it might be neon-sys
that is problematic. Can you try using the napi-runtime
backend for Neon? It isn't on feature parity yet, but might help confirm if this direction will work. Add the following to your Cargo.toml
:
neon = { version = "0.4.2", default-features = false, features = ["napi-runtime"] }
An alternative approach is to call into node.js with the EventHandler
API and have some glue code in javascript that creates a sandboxed worker to execute the Js.
Thank you, switching to napi-runtime worked perfectly. Now I can use js to call rust to call js :) Jokes aside, thank you so much for your help :)
Glad I could help! That means the issues may have to do with linking. There a few caveats that likely apply:
node.lib
napi-runtime
does not yet have a way to wrap Rust data in JS objects for management by the garbage collector. This is the JsClass
macro in current neon, but will be JsBox
. It has not landed yet: https://github.com/neon-bindings/neon/pull/579Task
API. That's currently in the RFC stage: https://github.com/neon-bindings/rfcs/pull/32napi-runtime
backend for Neon is not considered production ready. It's an active work in progress.Who needs windows support anyway? And the other stuff, I should be able to work around it, so no problems there
As the title says, using rusty_v8 is not working for me, im on Arch linux x86_64, Node v12.18.1, rustc 1.48.0-nightly (fb1dc34a8 2020-09-21) I made a simple project with
neon new neonb
, Filled it out with a basic skeleton for a discord bot, before adding some rust code to initialize the v8 js engine. it didnt work (Same error as below), so I started stripping away some code, until i was left with justconst rusty = require('../native')
andIf i remove the
use rusty_v8 as v8;
the code compiles just fine, but if I keep it, I get the following error on runtime:Im not sure if this is a problem, since rusty_v8 is a binding to Chromium's V8 engine, and neon isnt compatable with things of that nature, but any help on this would be greatly appreciated. I can give more information if needed. neon-cli version ^0.4.0 neon-build 0.4.0 neon 0.4.0