Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upchild_process: do not ignore proto values of env #18210
Conversation
apapirovski
added
the
fast-track
label
Jan 17, 2018
apapirovski
requested review from
jasnell,
addaleax,
benjamingr and
targos
Jan 17, 2018
nodejs-github-bot
added
the
child_process
label
Jan 17, 2018
This comment has been minimized.
This comment has been minimized.
|
Should we not revert this entirely? |
apapirovski
referenced this pull request
Jan 17, 2018
Closed
CITGM seems to be broken on master #536
This comment has been minimized.
This comment has been minimized.
We don't need to. Just the prototype portion is excluded. To be honest, IMO that portion of the change kind of snuck through because the documented part is only re: undefined values. |
apapirovski
added
the
semver-major
label
Jan 17, 2018
joyeecheung
referenced this pull request
Jan 17, 2018
Open
Check that a semver-major PR has at least a CITGM CI run #141
This comment has been minimized.
This comment has been minimized.
|
CI: https://ci.nodejs.org/job/node-test-pull-request/12586/ (Does CitGM use the newly built |
This comment has been minimized.
This comment has been minimized.
|
@apapirovski I think it does because the previous citgm errors seemed to be caused by citgm itself, not the modules that it was testing. |
This comment has been minimized.
This comment has been minimized.
|
Note that some of the modules tested by CitGM will fail on master: nodejs/citgm#517 |
evanlucas
approved these changes
Jan 17, 2018
apapirovski
referenced this pull request
Jan 17, 2018
Closed
child_process: ignore undef/proto values of env #15089
jasnell
approved these changes
Jan 17, 2018
addaleax
approved these changes
Jan 17, 2018
This comment has been minimized.
This comment has been minimized.
|
To be clear, my approval is not just +1 to landing this but also +1 to considering this the right behaviour. |
This comment has been minimized.
This comment has been minimized.
|
Why is this conceptually the right behavior? By far, the language conventions when reflecting on objects are for only including own enumerable properties - eg Object.keys/values/entries/assign and object spread. |
joyeecheung
added
the
author ready
label
Jan 18, 2018
mcollina
approved these changes
Jan 18, 2018
|
LGTM with a nit. |
| @@ -504,7 +504,7 @@ function normalizeSpawnArguments(file, args, options) { | |||
| var env = options.env || process.env; | |||
| var envPairs = []; | |||
|
|
|||
| for (const key of Object.keys(env)) { | |||
| for (var key in env) { | |||
This comment has been minimized.
This comment has been minimized.
mcollina
Jan 18, 2018
Member
I would add a comment that flag that states that copying the prototype values is intentional.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
I think it would be breakage without any reason, and it would not have landed if we were aware that it would break CITGM. Moreover, the change was introduced to fix #15087, which is definitely not about the prototype chain. @ljharb if you want to pursue this specific change, can you send a different PR so it can be discussed separately? |
targos
approved these changes
Jan 18, 2018
mcollina
referenced this pull request
Jan 18, 2018
Closed
stream: check type and range of highWaterMark #18098
This comment has been minimized.
This comment has been minimized.
|
Landed in 38ee25e |
apapirovski
closed this
Jan 18, 2018
apapirovski
deleted the
apapirovski:fix-env-prototype-key-values
branch
Jan 18, 2018
apapirovski
added a commit
that referenced
this pull request
Jan 18, 2018
addaleax
removed
the
author ready
label
Jan 18, 2018
This comment has been minimized.
This comment has been minimized.
|
@mcollina totally understand that the change was unintentional and breaking, so of course it should be reverted ASAP. Philosophically tho, im not sure why it’s desired. Before i invest time in pursuing a change, I’d love to understand why anyone thinks iterating the prototype is a good idea. @addaleax, can you (or anyone else if they share the opinion) elaborate on why? |
This comment has been minimized.
This comment has been minimized.
|
@ljharb I’m not sure, but it does feel more natural to me – in my head, the child’s |
This comment has been minimized.
This comment has been minimized.
|
We should look into why CITGM (or the modules it uses) relies on the prototype properties passed as env though. |
This comment has been minimized.
This comment has been minimized.
|
It’d be trivial to change: https://github.com/nodejs/citgm/blob/master/lib/create-options.js. |
This comment has been minimized.
This comment has been minimized.
|
In general, I'd be fine with limiting it to own properties only in a semver-major. |
This comment has been minimized.
This comment has been minimized.
|
What's not trivial is that there's an absolute ton of user-land code that relies on this behaviour: https://github.com/search?q=object.create%28process.env%29&type=Code&utf8=%E2%9C%93 It appears to be a VERY common pattern. |
This comment has been minimized.
This comment has been minimized.
|
That’s indeed a strong argument that it’s not worth the change, even if i think that “own keys only” is the correct/better conceptual model. |
apapirovski commentedJan 17, 2018
•
edited
This reverts part of the behaviour introduced in a recent PR, and updates the test. Without this change, CitGM and other packages are broken. I would like to have this fast-tracked (like, land within an hour or less) because as things are, CitGM is completely broken.
Also, I would like to propose, that going forward all changes that are labeled as semver-minor/major/patch MUST have a CitGM run to land. If any issues are found, collaborators & TSC should decide whether those are blocking or not. In either case, an effort should be made to fix the impacted modules before the PR lands — or at the very least in cases where those modules are integral to the Node.js core project.
Refs: 85739b6
Fixes: nodejs/citgm#536
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
child_process, test