Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.4k
lib: require globals instead of using the global proxy#27112
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
nodejs-github-bot commented Apr 6, 2019
nodejs-github-bot commented Apr 6, 2019
nodejs-github-bot commented Apr 6, 2019
nodejs-github-bot commented Apr 7, 2019
BridgeAR left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the benefit of using require instead of relying on the global proxy? Using the latter seems just simpler in this case?
Uh oh!
There was an error while loading. Please reload this page.
nodejs-github-bot commented Apr 9, 2019
BridgeAR commented Apr 9, 2019
@joyeecheung I am not sure what the benefit of using |
joyeecheung commented Apr 9, 2019
The latter is still subject to monkey-patching, so one could delete |
In addition, use process.stderr instead of console.error when there is no need to swallow the error.
nodejs-github-bot commented Apr 9, 2019
joyeecheung commented Apr 10, 2019
@BridgeAR Are your comments blocking? |
BridgeAR commented Apr 10, 2019
The builtins could still be directly manipulated (as in: the properties of the exports could be changed). For me the primordials are different since especially legacy code tends to add extra properties / functions on the prototype or changes behavior of some functions. Deleting properties from the global is something I never encountered so far (but it might still be done). But should we really guard against this case while not being able to guard against monkey patching the builtin in general?
I would like to at least discuss this a bit further. |
joyeecheung commented Apr 10, 2019 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
I think we should, or at least we should not start with letting things loose by default. If anyone actually has serious use case for this, we could explicitly use Specifically, what's the downside of guarding against monkey-patching like this? This is just a +42 −24 change, it's not really complex. |
joyeecheung commented Apr 13, 2019
@BridgeAR Does #27112 (comment) answer your question? |
joyeecheung commented Apr 15, 2019
Ping @BridgeAR |
joyeecheung commented Apr 15, 2019
Landed in a38e9c4 |
In addition, use process.stderr instead of console.error when there is no need to swallow the error. PR-URL: #27112 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Yongsheng Zhang <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
dsanders11 commented Jun 22, 2019
@BridgeAR, @joyeecheung, apologies for commenting on an old closed PR, but wanted to add a 👍for the change. Name clashes between globals can cause bugs in Electron's renderer process (like electron/electron#14915) when code in Node accidentally uses the global from Anyway, just throwing in my 2 cents on why this is a good PR. |
In addition, use process.stderr instead of console.error when there is no need to swallow the error. PR-URL: nodejs/node#27112 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Yongsheng Zhang <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
In addition, use process.stderr instead of console.error when
there is no need to swallow the error.
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes