-
Notifications
You must be signed in to change notification settings - Fork 30k
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
process.binding('spawn_sync') is required for spawn-wrap (and thus nyc) to work. #27344
Comments
@coreyfarrell Being able to implement code coverage metrics from tests is a pretty important quality of a language run-time, I'm wondering if something more maintainable can be proposed that would help multiple coverage providers. |
/to @nodejs/tooling |
We hook spawnSync is what I'm concerned about (sorry my initial post said spawnWrap). Right now c8 works by setting |
One of my hopes about having a Would this be a mechanism you could use? Broadly, it seems to have the same effect as prepending an alternative main js file in order to do pre-setup, as nyc is doing now. |
In theory a For either approach to a hypothetical |
Not necessarily, they could append. It doesn't seem so different from PATH. It can be replaced, or appended to, and all kinds of carnage can occur if its done wrongly. NODE_OPTIONS isn't set that much by node packages as they spawn children, because args can be put into ARGV more directly. Its mostly used in deployment before calling node or
An API like that, maybe using a "don't touch this directly"
Yes. I assume you do that already with the startup runner you insert into the ARGV, or a |
One concern I have is escaping in NODE_OPTIONS. I'm considering adding an option to nyc@15 which would allow it to bypass spawn-wrap and prepend NODE_OPTIONS instead. My concern is that I'm not sure what is required to ensure proper/safe escaping of the NODE_OPTIONS value. I'm not sure it's necessarily a security concern but I do want to ensure that nyc works properly even if |
@coreyfarrell Backslash escapes the next character and text in double quotes is parsed as a single string. E.g. |
It looks like the option to
From istanbuljs/nyc#1169 - not sure if you have any advice of how to properly escape/quote the path given to the process.env.NODE_OPTIONS = ' --require="/usr/src/npm/nyc/lib/wrap.js"'; In the above test |
Nevermind, I found #24065 and the linked nearform PR, so I'm using |
I discussed the current PR with @bcoe a few days ago, a concern we have with enabling the
I've created an experimental node-preload module that in theory could replace I realize this doesn't answer the question of "not just a nyc hack". In theory this could be used to implement a "all child processes" mode to |
@coreyfarrell @bcoe ... is this still an issue? |
@jasnell yes. Although nyc no longer uses How to best structure the API for this along with other core hooks is being investigated by the tooling team. |
Since this issue has been open for 2.5 years with no movement, I'll go ahead and close it. |
spawn-wrap works by intercepting calls to spawn and spawnSync. spawn is handled by replacing
ChildProcess.prototype.spawn
, spawnSync is handled by replacingprocess.bindings('spawn_sync').spawn
. With #22160 and #22260 I assume we will need a migration path in the future.CC @isaacs @bcoe
The text was updated successfully, but these errors were encountered: