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

Use Optional Chaining to globalThis.process.env.NODE_ENV Retrieval #4019

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

johnfabre
Copy link

This PR introduces optional chaining when accessing globalThis.process.env.NODE_ENV in the graphql-js codebase.

The current implementation assumes that globalThis.process.env is always defined, which may not be the case in all environments. This assumption leads to a runtime error when NODE_ENV is accessed on an undefined process.env.

By adding optional chaining (?.), we ensure that NODE_ENV is only accessed if globalThis.process and process.env are defined, thereby preventing potential runtime errors.

This change improves the robustness of the code and makes it more compatible with various JavaScript environments.

Copy link

linux-foundation-easycla bot commented Feb 12, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

Copy link

netlify bot commented Feb 12, 2024

Deploy Preview for compassionate-pike-271cb3 ready!

Name Link
🔨 Latest commit dd99b7e
🔍 Latest deploy log https://app.netlify.com/sites/compassionate-pike-271cb3/deploys/65c9e51f1faac900081b9445
😎 Deploy Preview https://deploy-preview-4019--compassionate-pike-271cb3.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@JoviDeCroock
Copy link

This is a duplicate of #4017

this will fix the issue where globalThis.process.env is undefined and it is still trying to retrieve NODE_ENV
@johnfabre
Copy link
Author

johnfabre commented Feb 12, 2024

CLA SignedThe committers listed above are authorized under a signed CLA.

added myself to CLA

This is a duplicate of #4017

used the code suggested in here
https://github.com/graphql/graphql-js/pull/4017/files#r1483265402

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants