graphql-js icon indicating copy to clipboard operation
graphql-js copied to clipboard

Use Optional Chaining to `globalThis.process.env.NODE_ENV` Retrieval

Open johnfabre opened this issue 1 year ago • 4 comments

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.

johnfabre avatar Feb 12 '24 08:02 johnfabre

CLA Signed

The committers listed above are authorized under a signed CLA.

  • :white_check_mark: login: johnfabre (dd99b7ee234f8c37ea3916a9f02d29a1a2c78a13)

Deploy Preview for compassionate-pike-271cb3 ready!

Name Link
Latest commit dd99b7ee234f8c37ea3916a9f02d29a1a2c78a13
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.

netlify[bot] avatar Feb 12 '24 08:02 netlify[bot]

This is a duplicate of https://github.com/graphql/graphql-js/pull/4017

JoviDeCroock avatar Feb 12 '24 08:02 JoviDeCroock

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

johnfabre avatar Feb 12 '24 09:02 johnfabre

Fixed with https://github.com/graphql/graphql-js/pull/4022

JoviDeCroock avatar Jul 11 '24 18:07 JoviDeCroock