Skip to content

Conversation

@aduh95
Copy link
Contributor

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-botnodejs-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
@aduh95aduh95 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

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

@jasnelljasnell 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]>
@aduh95aduh95force-pushed the globalThis-primordials branch from 864ed83 to 9d46c81CompareApril 13, 2021 16:34
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]>
@aduh95aduh95force-pushed the globalThis-primordials branch from 9d46c81 to 23d2c54CompareApril 13, 2021 16:34
@aduh95
Copy link
ContributorAuthor

Landed in 23d2c54

@aduh95aduh95 merged commit 23d2c54 into nodejs:masterApr 13, 2021
@aduh95aduh95 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]>
@richardlaurichardlau 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 freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.fast-trackPRs that do not need to wait for 48 hours to land.lib / srcIssues and PRs related to general changes in the lib or src directory.needs-ciPRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@aduh95@nodejs-github-bot@jasnell@richardlau@bmeck@marsonya@targos