-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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: freeze process.features #28242
Conversation
Sadly, an error occurred when I tried to trigger a build. :( |
Hm, any particular reason for doing so? It seems like this might get in the way of mocking for testing, and I don’t really see how one would modify this object accidentally (= not on purpose) |
Yeah, I'm not sure there's a really good reason to do this |
@addaleax See #25343 (comment) Not that I feel very strongly about this PR in particular, but from my experience mocking Node.js to test anything is usually a bad idea - that means the test can be easily broken by upstream changes that do not affect the functionality that you are actually testing, which would've been impossible if the code is written in some other stricter language or more robust platform. Not just mocking the platform - even mocking your own code can lead to very fragile tests. |
also consider that a library may polyfill functionality and wish to therefore modify process.features. |
My point about freezing is that a malicious library/actor could modify values and break software relying on Mocking for tests is not a valid reason to not freeze imho. We could instead just introduce a internal flag that is set during test runs which would not freeze it instead. |
To clarify, when I talked about tests I was talking about other people’s tests, not ours. But more generally, I dislike the idea of giving JS objects special behaviour unless there’s a very solid reason to do so; JS objects are writable by default, and each exception is going to break somebody’s expectations (aka principle of least surprise). |
What should be done here? |
I agree that allowing polyfills to modify this is a valid use case, so I will close this. |
Refs: #25343
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes