fix(process): validate CPU snapshots and listener limits#3496
Merged
proggeramlug merged 2 commits intoMay 31, 2026
Merged
Conversation
This was referenced May 31, 2026
# Conflicts: # crates/perry-runtime/src/os.rs # crates/perry-runtime/src/process.rs # docs/runtime-parity-gaps.md
proggeramlug
pushed a commit
that referenced
this pull request
May 31, 2026
`crates/perry-runtime/src/process.rs` reached 2047 LOC on main after the node:process argument-validation batch (#3493/#3516/#3518/#3496) landed without a split, tripping the whole-tree file-size gate and turning every open PR's `lint` check red. Add it to the allowlist with a rationale, mirroring the existing entries; the per-concern split is tracked under #1435.
proggeramlug
added a commit
that referenced
this pull request
May 31, 2026
…3149) (#3530) * fix(es5): Object(value) plain-call coercion returns a fresh object (#3149) Bug 1 of #3149. `Object()` / `Object(undefined)` / `Object(null)` called as a plain function (not `new`) returned `undefined` — the bare-call path fell through to the generic dispatcher. Per ECMAScript §20.1.1.1 these yield a fresh ordinary `{}`; an existing object/array/function passes through unchanged; a primitive coerces to an object (typeof "object"). Adds an `Expr::ObjectCoerce(value)` HIR variant (mirroring `StringCoerce`) lowered from the shadow-safe bare `Object(...)` call, a `js_object_coerce` runtime helper (nullish/primitive -> fresh `{}`, pointer passes through), and codegen emission + the operand-recursing collector/walker arms. The `new Object(null)` path already worked via `js_new_function_construct`. Gap test `test_gap_3149_object_coerce.ts` is byte-identical to `node --experimental-strip-types`. Bug 2 (function-declaration reassignment) is intentionally deferred — see the follow-up issue; it needs mutable-binding-slot routing across the FuncRef read / call / `new` lowering sites and human review before landing. * chore(lint): allowlist process.rs in the file-size gate `crates/perry-runtime/src/process.rs` reached 2047 LOC on main after the node:process argument-validation batch (#3493/#3516/#3518/#3496) landed without a split, tripping the whole-tree file-size gate and turning every open PR's `lint` check red. Add it to the allowlist with a rationale, mirroring the existing entries; the per-concern split is tracked under #1435. * docs: regenerate API reference + .d.ts to match the manifest The committed artifacts were one batch stale relative to crates/perry-api-manifest/src/entries.rs: #3528 (util.debuglog factory) dropped the `util.debug` / `sys.debug` alias from the manifest but the merge didn't regenerate docs, leaving main red on the api-docs-drift gate (committed docs claim 1996 entries; manifest has 1994). Re-run of `./scripts/regen_api_docs.sh` — no manifest change in this PR, purely a catch-up regeneration. --------- Co-authored-by: Ralph Küpper <ralph@skelpo.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
process.cpuUsage(previousValue)andprocess.threadCpuUsage(previousValue)snapshot inputs with Node-shaped error behavior and delta resultsthreadCpuUsage(previousValue)through HIR/codegen and dynamicprocessnamespace dispatchprocess.exit(code)for accepted integer numbers/string-integers and invalid numeric valuesInfinityprocess.setMaxListeners()readback, validate invalid values, and return theprocessnamespace objectBatched Issues
Closes #3040
Closes #2927
Closes #3041
Closes #3049
These share the
processruntime validation/readback path and one deterministic parity surface.Tests Added
test-parity/node-suite/process/cpu/usage-prev-validation.tstest-parity/node-suite/process/events/max-listeners-validation.tstest-parity/node-suite/process/methods/exit-validation.tsVerification
test-parity/reports/parity_report_20260531_002702.jsontest-parity/reports/parity_report_20260531_003800.jsontest-parity/reports/parity_report_20260531_004456.jsonTMPDIR="$PWD/target/tmp" CARGO_BUILD_JOBS=1 RUSTC_WRAPPER= cargo check -p perry-runtime -p perry-codegen -p perry-api-manifest -p perry-codegen-js -p perry-codegen-wasmpassed with existing warningscargo fmt --all -- --checkgit diff --check HEAD./scripts/check_file_size.shKnown Limitations
threadCpuUsagestill follows Perry's existing host-clock approximation for the user/system split; this PR fixes validation and previous-value delta semantics.Non-goals
process.execve, process IPC channel behavior, worker CPU APIs, and broader EventEmitter warning behavior.