Skip to content

feat(process): implement process.loadEnvFile as no-op stub (#1399)#1505

Merged
proggeramlug merged 1 commit into
mainfrom
fix/1399-load-env-file
May 23, 2026
Merged

feat(process): implement process.loadEnvFile as no-op stub (#1399)#1505
proggeramlug merged 1 commit into
mainfrom
fix/1399-load-env-file

Conversation

@proggeramlug
Copy link
Copy Markdown
Contributor

Summary

Node 20.12+ exposes process.loadEnvFile(path?) to read a .env file from disk and add its KEY=value entries to process.env. Perry was reading it as a bare number — typeof process.loadEnvFile === "function" returned false and call sites crashed with "value is not a function".

Perry today doesn't persist process.env.X = v writes (tracked in #1344), so eagerly loading a .env would be moot. Returning undefined is the closest no-op for the probe-and-call pattern. Real .env loading is tracked separately — this PR closes the typeof / call-doesn't-crash gap.

Closes #1399.

Changes

  • Call lowering (native_module.rs): folds to Expr::Undefined, sitting next to the ref / unref / setSourceMapsEnabled / getBuiltinModule / dlopen / hasUncaughtExceptionCaptureCallback / setUncaughtExceptionCaptureCallback arms.
  • Typeof fold (lower_expr.rs): adds loadEnvFile to the same process-method-as-function list.

Test plan

Node 20.12+ exposes `process.loadEnvFile(path?)` to read a `.env`
file from disk and add its KEY=value entries to process.env. Perry
was reading it as a bare number, so `typeof process.loadEnvFile ===
"function"` returned false and call sites crashed with "value is not
a function".

Perry today doesn't persist `process.env.X = v` writes (tracked in
#1344), so eagerly loading a `.env` would be moot. Returning
undefined is the closest no-op for the probe-and-call pattern. Real
`.env` loading is tracked separately — this PR closes the typeof /
call-doesn't-crash gap.

- Call lowering (`native_module.rs`): folds to `Expr::Undefined`,
  sitting next to the `ref` / `unref` / `setSourceMapsEnabled` /
  `getBuiltinModule` / `dlopen` / `hasUncaughtExceptionCaptureCallback`
  / `setUncaughtExceptionCaptureCallback` arms.
- Typeof fold (`lower_expr.rs`): adds `loadEnvFile` to the same
  process-method-as-function list.

Test: test-parity/node-suite/process/methods/load-env-file.ts (in
the granular suite from #1331) now passes — byte-identical to
`node --experimental-strip-types`.
@proggeramlug proggeramlug merged commit b3adea1 into main May 23, 2026
9 checks passed
@proggeramlug proggeramlug deleted the fix/1399-load-env-file branch May 23, 2026 10:55
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.

node:process — implement process.loadEnvFile(path?)

1 participant