Skip to content

fix(node:process): loadEnvFile path handling, error-event semantics, sourceMaps toggle#3684

Merged
proggeramlug merged 3 commits into
mainfrom
fix-process-misc-3045-3052-3108
May 31, 2026
Merged

fix(node:process): loadEnvFile path handling, error-event semantics, sourceMaps toggle#3684
proggeramlug merged 3 commits into
mainfrom
fix-process-misc-3045-3052-3108

Conversation

@proggeramlug
Copy link
Copy Markdown
Contributor

@proggeramlug proggeramlug commented May 31, 2026

Summary

Three node:process parity fixes, validated byte-for-byte against node --experimental-strip-types.

Closes #3045
Closes #3052
Closes #3108

Implementation

  • node:process: match loadEnvFile path argument handling #3045loadEnvFile path handling was already implemented on main: the dispatch passes the full JS value to js_process_load_env_file, which defaults omitted/undefined/null to .env, accepts string/Buffer/file: URL via decode_path_value, and throws the exact Node ERR_INVALID_ARG_TYPE message for other types. This PR adds the gap-test coverage proving it byte-identical (string/Buffer/URL load, invalid types throw, default-.env ENOENT), so the issue is verified closed; no runtime change was required.
  • node:process: match unhandled error event throwing semantics #3052 — unhandled error event (crates/perry-runtime/src/os.rs): emit_process_event now routes the no-listener error case through throw_unhandled_error_event. An Error instance (or subclass, via js_util_types_is_native_error) is rethrown as-is, preserving identity/code. Any other value (including a missing argument) throws a fresh Error with code: "ERR_UNHANDLED_ERROR" and message Unhandled error. (<util.inspect(arg)>) — matching Node's 'boom', 42, null, true, undefined formatting.
  • node:process: implement source map toggle state #3108 — sourceMaps toggle: added a runtime AtomicBool flag plus js_process_source_maps_enabled (getter) and js_process_set_source_maps_enabled (setter with boolean validation → ERR_INVALID_ARG_TYPE) in crates/perry-runtime/src/process.rs, each pinned with a #[used] keepalive anchor for the auto-optimize whole-program link. Wired through codegen: native-table sigs (node_core.rs), runtime decls (runtime_decls/strings.rs), and HIR lowering (expr_member.rs getter arms → 0-arg NativeMethodCall, expr_call/native_module.rs setter → NativeMethodCall forwarding the argument). The flag starts false and round-trips through setSourceMapsEnabled(true|false).

No new HIR Expr variant.

Validation

test-files/test_gap_process_misc_3045plus.ts is byte-identical to Node v25.8.0 under the default auto-optimize compile (exercises the new #[no_mangle] FFIs end-to-end; link succeeds → keepalive anchors confirmed). Guards green: ./scripts/check_file_size.sh, cargo fmt --all -- --check, cargo test --release -p perry-runtime process, cargo test --release -p perry-hir (132 passing incl. expr_variant_stable_hash_tags_are_unique).

@proggeramlug proggeramlug merged commit 9aba91b into main May 31, 2026
8 of 11 checks passed
@proggeramlug proggeramlug deleted the fix-process-misc-3045-3052-3108 branch May 31, 2026 11:20
proggeramlug added a commit that referenced this pull request May 31, 2026
…dicate tail (#3702)

* fix(node): fill constants tail (constants/zlib Zstd) + util.types predicate tail

#3683 node:constants — add POSIX file-flag (S_IF*, O_DIRECTORY/O_NOCTTY/
O_NONBLOCK/O_SYNC/O_DSYNC/O_SYMLINK), libuv (UV_DIRENT_*, UV_FS_SYMLINK_*,
UV_FS_COPYFILE_*), and defaultCoreCipherList metadata to both the value-read
dispatch (constants + fs.constants) and the enumerable-keys list. O_* use
libc on Unix for host-accurate parity; S_IF* are POSIX-standard.

#3677 node:zlib — Object.keys(zlib.constants) now enumerates the full 170-key
Z_*/BROTLI_*/ZSTD_* set Node exposes (was 0). Added the missing Brotli decoder
result/error codes and the ZSTD_error_* codes to the value-read dispatch so
every enumerated key reads its backing value.

#3678 node:util/types — add the predicate tail Perry can correctly back:
isDataView, isFloat16Array, isWeakMap, isWeakSet, isExternal. Dropped
isBigIntObject/isSymbolObject (Perry boxes only Number/String/Boolean),
isArgumentsObject (no distinct arguments object), isModuleNamespaceObject,
isKeyObject, isCryptoKey (no backing value type) — a false-always stub would
lie about Node's positive cases.

Also adds the missing manifest rows for process.sourceMapsEnabled /
setSourceMapsEnabled (drift from #3684) so manifest-consistency stays green.

* regen docs after merge (constants tail)

---------

Co-authored-by: Ralph Küpper <ralph@skelpo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant