-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
lib: add late code injector #37503
lib: add late code injector #37503
Conversation
Should this be documented? Does this need a test? |
Co-authored-by: Gireesh Punathil <gpunathi@in.ibm.com>
@Trott yes, will surely add documentation + tests for this after |
In the current form, this should definitely be implemented in userland through |
Yeah, without more information about the specific set of use cases being targeted here, I have to agree with @addaleax |
@addaleax - how does that work? with |
@gireeshpunathil at startup, load a small module loader script, instead of the main script: 'use strict';
process.on('SIGUSR1', () => {
require(process.env.THE_MODULE);
delete require.cache[require.resolve(process.env.THE_MODULE)];
}); |
@devsnek - makes sense, in the given premise of this PR ( there are certain preparation possible prior to the process launch). However, the original issue does not have such a premise. How do we run an arbitrary piece of code in a running process, where the process did not undergo any preparatory steps. This PR is probably a middleground approach wherein the name of the module is set on the
, not because we have that flexibility. |
If you want to run arbitrary code after launch, why not start a tcp server in conjunction with |
I wouldn't call this PR a midde ground, though, because it has the exact same set of requirements as what @devsnek and I would be suggesting. If you want a no-preparation-at-all scenario, then you'll need a different approach. |
@mscdex - that needs the target process to be prepared for receiving an arbitrary code, right? Here is my requirement, restating:
|
@addaleax - yes agree. Please let @RaisinTen / me know if you have ideas on those lines. |
@gireeshpunathil It sounds like what you're wanting is impossible then. Even with this PR it requires an environment variable on startup of the process? |
@mscdex - agree, this PR assumes we are informed about a future attach. |
Thanks for the reviews. Closing in favour of #37748. |
Fixes: #37440