Skip to content
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: add globalThis to primordials #38211

Merged
merged 1 commit into from
Apr 13, 2021
Merged

Conversation

aduh95
Copy link
Contributor

@aduh95 aduh95 commented Apr 12, 2021

This is useful to avoid throwing exception if globalThis is being overwritten in userland:

> node -e 'globalThis.globalThis = null;new Error().stack'
node:internal/process/execution:92
    globalThis.module = origModule;
                      ^

TypeError: Cannot set property 'module' of null
    at evalScript (node:internal/process/execution:92:23)
    at node:internal/main/eval_string:23:3

I'm using no-restricted-globals instead of node-core/prefer-primordials to generate better error messages.

lib/internal/process/execution.js
  58:22  error  Use `const { globalThisModule } = primordials;` instead of the global      node-core/prefer-primordials
  75:3   error  Use `const { globalThis__filename } = primordials;` instead of the global  node-core/prefer-primordials
  92:5   error  Use `const { globalThisModule } = primordials;` instead of the global      node-core/prefer-primordials
lib/internal/process/execution.js
  58:22  error  Unexpected use of 'globalThis'. Use `const { globalThis } = primordials;` instead of the global  no-restricted-globals
  75:3   error  Unexpected use of 'globalThis'. Use `const { globalThis } = primordials;` instead of the global  no-restricted-globals
  92:5   error  Unexpected use of 'globalThis'. Use `const { globalThis } = primordials;` instead of the global  no-restricted-globals

@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Apr 12, 2021
@aduh95 aduh95 added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 12, 2021
@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot
Copy link
Collaborator

nodejs-github-bot commented Apr 13, 2021

@jasnell
Copy link
Member

jasnell commented Apr 13, 2021

CI is green and seems uncontroversial. There's no reason for this to wait the full 48 hours. Please 👍🏻 to fast-track

@jasnell jasnell added the fast-track PRs that do not need to wait for 48 hours to land. label Apr 13, 2021
PR-URL: nodejs#38211
Reviewed-By: Bradley Farias <[email protected]>
Reviewed-By: James M Snell <[email protected]>
aduh95 added a commit to aduh95/node that referenced this pull request Apr 13, 2021
PR-URL: nodejs#38211
Reviewed-By: Bradley Farias <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@aduh95
Copy link
Contributor Author

aduh95 commented Apr 13, 2021

Landed in 23d2c54

@aduh95 aduh95 merged commit 23d2c54 into nodejs:master Apr 13, 2021
@aduh95 aduh95 deleted the globalThis-primordials branch April 13, 2021 16:36
aduh95 added a commit to aduh95/node that referenced this pull request Jul 19, 2021
PR-URL: nodejs#38211
Reviewed-By: Bradley Farias <[email protected]>
Reviewed-By: James M Snell <[email protected]>
richardlau pushed a commit that referenced this pull request Jul 20, 2021
PR-URL: #38211
Backport-PR-URL: #39448
Reviewed-By: Bradley Farias <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@richardlau
Copy link
Member

Backported to v14.x-staging in #39448.

richardlau pushed a commit that referenced this pull request Jul 20, 2021
PR-URL: #38211
Backport-PR-URL: #39448
Reviewed-By: Bradley Farias <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@richardlau richardlau mentioned this pull request Jul 20, 2021
foxxyz pushed a commit to foxxyz/node that referenced this pull request Oct 18, 2021
PR-URL: nodejs#38211
Backport-PR-URL: nodejs#39448
Reviewed-By: Bradley Farias <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. fast-track PRs that do not need to wait for 48 hours to land. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants