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

Any way to reload the built-in modules? #3087

Closed
RaisinTen opened this issue Nov 19, 2020 · 9 comments
Closed

Any way to reload the built-in modules? #3087

RaisinTen opened this issue Nov 19, 2020 · 9 comments

Comments

@RaisinTen
Copy link
Contributor

Is there any way to reload the built-in modules into the node executable generated by make without recompiling the C++ part entirely?

@richardlau
Copy link
Member

There's some functionality that was added in nodejs/node#31321. You will need to rebuild Node.js once with the --node-builtin-modules-path configure option to enable it.

@RaisinTen
Copy link
Contributor Author

Thank you so much!

Which of these two should I execute at the top of the git repo of node:

  • ./configure --node-builtin-modules-path=.
    
  • ./configure --node-builtin-modules-path=lib
    

Both seem to produce the same output:

Node.js configure: Found Python 3.6.9...
Warning! Loading builtin modules from disk is for development
INFO: configure completed successfully

@richardlau
Copy link
Member

It looks like between those two choices it would be the first as lib gets appended:
https://github.com/nodejs/node/blob/bb3cbba9533b37429292fd1005efb8099e7ba872/src/node_native_module.cc#L198

(FWIW I've never used this build feature before)

@RaisinTen
Copy link
Contributor Author

Thank you for the help. I'll try using it. 🙂

@RaisinTen
Copy link
Contributor Author

After building node with this mod I figured out that I should have used the absolute path to the node git repo instead. When using node from a different location, I get this error:

node/node[3415]: ../src/node_native_module.cc:215:v8::MaybeLocal<v8::String> node::native_module::NativeModuleLoader::LoadBuiltinModuleSource(v8::Isolate*, const char*): Assertion `(req.result) >= (0)' failed.

I was thinking about changing this functionality a bit. Instead of fixing the path in the configuration stage maybe we can enable this feature using a binary flag and during execution node will read in the builtin modules path from an environment variable.

@devsnek
Copy link
Member

devsnek commented Nov 21, 2020

@RaisinTen if you give it an absolute path you won't have that issue.

@bl-ue
Copy link

bl-ue commented Jun 8, 2021

@RaisinTen did you ever get it working? I tried running this:

./configure --debug --debug-node --gdb --v8-non-optimized-debug --v8-enable-object-print --debug-nghttp2 --node-builtin-modules-path=$PWD/lib --enable-asan --debug-lib

but the resulting node aborts, just like yours did.

❯ echo $PWD/lib
/Users/me/node/lib

@RaisinTen
Copy link
Contributor Author

@bl-ue Yes, this works for me. :)
I think the value for --node-builtin-modules-path should be set to just $PATH without the /lib suffix because #3087 (comment).

@bl-ue
Copy link

bl-ue commented Jun 8, 2021

Ohhh... I saw that message, but I didn't read it correctly. Makes perfect sense. Thank you 👍🏻

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

4 participants