-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Why can Module.prototype.require
be deleted?
#41095
Comments
#30697 is being discussed. It is an open question as to whether and how far Node.js should go to prevent |
Module.prototype.require
deleted?Module.prototype.require
be deleted?
My impression was that the ECMA-262 API components were the only things that needed to be in Is the mutability of |
@nodejs/modules |
The primordials discussion is about language builtins; there is currently no plan or discussion or expectation I'm aware of about mutation of node's builtins themselves being supported - there's plenty of use cases that require node's builtins to be mutable, like monitoring systems. In general, don't mutate things you don't own; the goal of primordials is that mutating something unrelated to a node builtin should not break that builtin. If you mutate any arbitrary thing you don't own, you should always expect that thing to break. |
Can I get an answer to the question in my second paragraph? |
I assume that many use cases would break if it were locked down, yes - there’s a reason language and web builtins are mutable by default too. |
Mostly yes, though some use |
Version
v18.0.0-pre
Platform
No response
Subsystem
No response
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
No.
What is the expected behavior?
"Monkey patching" Node's internals is supposed to be impossible.
What do you see instead?
No response
Additional information
Per issue #30697, Node's internals were refactored to make them immune to modification by non-builtin code. So I am wondering why is it that
Module.prototype
is exposed to external code that can kill Node's module loading mechanism by deleting the propertyrequire
on it?The text was updated successfully, but these errors were encountered: