-
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
lib: expose primordials object #36872
Conversation
Can you move this to |
@devsnek Note that the current implementation requires to use two flags: |
I don't really like this solution for the referenced issue. The fact that we use built-in functions like |
A lot of the purpose in making the slow migration to |
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.
primordials was introduced exactly to prevent mutating the internals of node core and to allow robustness in the core. I don't think this approach to solve the referenced issue is the way we should approach it.
It looks like |
@bmeck is right – this PR would basically make having primordials pointless (which, yay, I think removing them would be a great idea, but I don’t think that’s happening). However, I’m commenting because I saw the issue title and thought “hey, maybe this is just exposing the deep-frozen object as-is”, which I think I’d like because it would help with Node.js core development (it answers questions like “What is in the primordials object” and “What happens when I run this piece of Node.js core source code”) and wouldn’t really hurt anyone. |
Actually, this won’t work the way it’s intended due to the way the This is because all code that uses the |
Thank you everyone for the reviews, I've rolled back the "altering primordials" part, this PR is now only exposing the Note to whoever lands this: the commit message will need to be amended before landing to remove the reference to sinonjs/fake-timers#344. |
I do think we can address the timer issue somewhere else; even if we didn't use primordials, early destructuring would have broken that as well like @ExE-Boss points out. |
a18f3ca
to
ba79489
Compare
Based on feedback shared by several persons, I've updated this PR to remove the The intended use of this feature is to use $ node lib/fs.js
…/node/lib/fs.js:51
} = primordials;
^
ReferenceError: primordials is not defined
at Object.<anonymous> (…/node/lib/fs.js:51:5)
at Module._compile (node:internal/modules/cjs/loader:1108:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
at Module.load (node:internal/modules/cjs/loader:973:32)
at Function.Module._load (node:internal/modules/cjs/loader:813:14)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
at node:internal/main/run_main_module:17:47
$ node --expose-internals -r internal/test/binding lib/fs.js
(node:5299) internal/test/binding: These APIs are for internal testing only. Do not use them.
(Use `node --trace-warnings ...` to show where the warning was created) |
On a side note, we might want to rename |
ba79489
to
b74793f
Compare
Where do we use the |
Not sure what you mean,
The idea is to give the ability for a |
Expose the internal `primordials` object to help with Node.js core development. ```console $ node --expose-internals -r internal/test/binding lib/fs.js (node:5299) internal/test/binding: These APIs are for internal testing only. Do not use them. (Use `node --trace-warnings ...` to show where the warning was created) ``` PR-URL: nodejs#36872 Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2f67dae
to
983e922
Compare
Landed in 983e922 |
Expose the internal `primordials` object to help with Node.js core development. ```console $ node --expose-internals -r internal/test/binding lib/fs.js (node:5299) internal/test/binding: These APIs are for internal testing only. Do not use them. (Use `node --trace-warnings ...` to show where the warning was created) ``` PR-URL: #36872 Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Expose the internal `primordials` object to help with Node.js core development. ```console $ node --expose-internals -r internal/test/binding lib/fs.js (node:5299) internal/test/binding: These APIs are for internal testing only. Do not use them. (Use `node --trace-warnings ...` to show where the warning was created) ``` PR-URL: #36872 Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Expose the internal `primordials` object to help with Node.js core development. ```console $ node --expose-internals -r internal/test/binding lib/fs.js (node:5299) internal/test/binding: These APIs are for internal testing only. Do not use them. (Use `node --trace-warnings ...` to show where the warning was created) ``` PR-URL: #36872 Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Expose the internal `primordials` object to help with Node.js core development. ```console $ node --expose-internals -r internal/test/binding lib/fs.js (node:5299) internal/test/binding: These APIs are for internal testing only. Do not use them. (Use `node --trace-warnings ...` to show where the warning was created) ``` PR-URL: #36872 Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Expose the internal `primordials` object to help with Node.js core development. ```console $ node --expose-internals -r internal/test/binding lib/fs.js (node:5299) internal/test/binding: These APIs are for internal testing only. Do not use them. (Use `node --trace-warnings ...` to show where the warning was created) ``` PR-URL: #36872 Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Provide a way to expose the
primordials
on the global object. This is useful to run Node.js internals modules to help with Node.js core development.