-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
cli: add flag for disabling globals #50554
Conversation
Review requested:
|
One concern I had while working on this is that there seems to be a progression where features move from |
I was also surprised to learn that |
$ echo 'console.log("crypto" in globalThis)' | node
true
$ echo 'console.log("crypto" in globalThis)' | node --no-experimental-global-webcrypto
false
|
This flag was introduced as
Unless I'm missing something, we would still need to add new flags unless we have a |
If i specify a global that’s not permitted to be suppressed, does node fail to start? I’d hope so. |
I was testing via |
|
What do we think about
To add to that, both |
I don't see the point of this flag. It creates a non-standard runtime that makes libraries more likely to break. No library author is going to test the complete matrix of globals that can be erased. It's also not like removing globals at startup isn't something you can't already do. This flag has zero merit, IMO. |
For globals that we add flagged, like behind flags like The other motivation was to limit the endless growth of flags. I find it terrible for UX that we have over a hundred flags. If these “disable” flags are temporary, like if we plan to remove For me that’s the big question: is disabling certain globals meant to be temporary, until the new global is stable, or is it a permanent feature we want to support? If we need a way to disable
Sure. That would solve the “but removing |
Landing new globals behind a flag first has an upside you forgot to mention: it makes their introduction non-semver-major, allowing backports and therefore earlier feedback plus it makes it easier for library maintainers to reproduce/isolate bugs related to the new globals. I think those experimental flags should go (become no op) at some point, maybe once all the non-EOL release lines have the global by default. |
They can't become no-ops because then they'd be broken; like If they're all meant to be temporary then sure, I prefer #50562. |
When a boolean flag becomes a no-op, it can stay as only one form – e.g. you can still do |
I was thinking of If that’s the case then yes I prefer #50562, I’d rather not support disabling globals indefinitely if they can graduate to being permanently enabled. This PR was made under the assumption that the ability to disable would need to be provided indefinitely. |
Per #50412 (comment), this creates a new flag
--disable-global
to provide the user a way to disable certain global APIs. The globals that can be disabled includeCustomEvent
,fetch
(and its associatedFormData
,Headers
,Request
, andResponse
),navigator
, andWebSocket
.The motivation for this flag is both to provide a compatibility escape hatch and also to abstract this ability for future global APIs. We currently have several flags for specific web APIs, like
--no-experimental-fetch
and--no-experimental-global-customevent
; as we continue to add web APIs, which are often globals, these per-API flags will proliferate. Rather than continue to grow our long list of CLI flags, a single flag that takes multiple options seems preferable.@nodejs/web-standards @nodejs/tsc