Skip to content

Commit

Permalink
fix(ext/node): set process.env as own property (#27891)
Browse files Browse the repository at this point in the history
Fixes `[email protected]`

```
% deno eval "import 'npm:[email protected]'" # main
error: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'GOOGLE_SDK_NODE_LOGGING')
    at Object.log (file:///Users/divy/Library/Caches/deno/npm/registry.npmjs.org/google-logging-utils/0.0.2/build/src/logging-utils.js:356:36)
    at Object.<anonymous> (file:///Users/divy/Library/Caches/deno/npm/registry.npmjs.org/gcp-metadata/6.1.1/build/src/index.js:52:20)
    at Object.<anonymous> (file:///Users/divy/Library/Caches/deno/npm/registry.npmjs.org/gcp-metadata/6.1.1/build/src/index.js:409:4)
    at Module._compile (node:module:745:34)
    at loadMaybeCjs (node:module:770:10)
    at Object.Module._extensions..js (node:module:755:12)
    at Module.load (node:module:662:32)
    at Function.Module._load (node:module:534:12)
    at Module.require (node:module:681:19)
    at require (node:module:812:16)

% target/debug/deno eval "import 'npm:[email protected]'" # this PR
```

---------

Signed-off-by: Divy Srivastava <[email protected]>
Co-authored-by: Yoshiya Hinosawa <[email protected]>
  • Loading branch information
littledivy and kt3k authored Jan 31, 2025
1 parent d9db0b3 commit 08cc221
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions ext/node/polyfills/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,7 @@ const process = new Process();

/* Set owned property */
process.versions = versions;
process.env = env;

Object.defineProperty(process, Symbol.toStringTag, {
enumerable: false,
Expand Down
2 changes: 2 additions & 0 deletions tests/unit_node/process_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,8 @@ Deno.test({
Deno.test({
name: "process.env",
fn() {
assert(Object.prototype.hasOwnProperty.call(process, "env"));

Deno.env.set("HELLO", "WORLD");

assertObjectMatch(process.env, Deno.env.toObject());
Expand Down

0 comments on commit 08cc221

Please sign in to comment.