-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
properties created using Symbols in process.env are not intercepted #9429
Comments
I am not sure… what behaviour would you expect? |
The vm module intercepts both Strings and Symbols, while the current version of the process.env supports only Strings. This is to ensure that the properties are treated in the same way, no matter how they were created. |
You’re right. But what do you think should happen when somebody does |
Also keep in mind that |
Having a flag makes strings optional + Symbols are commonly used, so my thinking is that it 'should' read and set values. That said, my understanding of the design choices here is limited and curious to hear all the perspectives. |
The default stringification for symbols isn't very useful ( Setting a symbol as the value already throws an exception (the 'Cannot convert a Symbol value to a string' error mentioned above.) Throwing on symbol keys would make it symmetrical. |
I'd definitely be in favor of having a more specific |
This commit causes process.env to throw when a symbol is used as either a key or a value. Fixes: nodejs#9429 PR-URL: nodejs#9446 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Daniel Bevenius <[email protected]> Reviewed-By: Minwoo Jung <[email protected]>
This commit causes process.env to throw when a symbol is used as either a key or a value. Fixes: nodejs#9429 PR-URL: nodejs#9446 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Daniel Bevenius <[email protected]> Reviewed-By: Minwoo Jung <[email protected]>
switching off the flag PropertyHandlerFlags::kOnlyInterceptStrings in node.cc
causes Type Error when intercepting via Symbols on process.env collection,
which is strongly typed for Strings (error in EnvSetter in node.cc).
to reproduce: switch off the flag and run /test/parralel/test-v8-interceptStrings-not-Symbols.js
The text was updated successfully, but these errors were encountered: