Skip to content

fix(process): validate usage snapshots and exit codes#3497

Closed
andrewtdiz wants to merge 1 commit into
PerryTS:mainfrom
andrewtdiz:codex/node-compat-process-validation
Closed

fix(process): validate usage snapshots and exit codes#3497
andrewtdiz wants to merge 1 commit into
PerryTS:mainfrom
andrewtdiz:codex/node-compat-process-validation

Conversation

@andrewtdiz
Copy link
Copy Markdown
Contributor

Summary

Closes #3040
Closes #2927
Closes #3041
Closes #3049

  • validate process.cpuUsage(previousValue) objects like Node, including array/non-object rejection, required numeric user/system, and finite non-negative counters
  • add process.threadCpuUsage(previousValue) lowering/codegen/runtime support with the same previous-value validation and delta calculation
  • align process.exit(code) validation for numeric strings, fractional values, NaN/Infinity, and non-number inputs
  • validate process.setMaxListeners(n), preserve fractional/Infinity listener limits, and return the real process object for chaining

Why Batched

These issues all sit in node:process validation/readback behavior, share the same parity harness surface, and reuse the same runtime helpers for Node-style numeric/error formatting.

Tests Added

  • test-parity/node-suite/process/cpu/cpu-usage-validation.ts
  • test-parity/node-suite/process/cpu/thread-cpu-usage-previous.ts
  • test-parity/node-suite/process/events/max-listeners-validation.ts
  • test-parity/node-suite/process/methods/exit-validation.ts

Verification

Using Node v25.9.0 on PATH for parity expected output:

  • ./run_parity_tests.sh --suite node-suite --module process --filter validation - 4 pass, 0 fail
  • ./run_parity_tests.sh --suite node-suite --module process/cpu --filter thread-cpu-usage-previous - 1 pass, 0 fail
  • ./run_parity_tests.sh --suite node-suite --module process/cpu - 5 pass, 0 fail
  • ./run_parity_tests.sh --suite node-suite --module process/events - 8 pass, 0 fail
  • ./run_parity_tests.sh --suite node-suite --module process/methods - 12 pass, 0 fail
  • cargo check -p perry-runtime -p perry-hir -p perry-codegen -p perry
  • cargo build --release --quiet -p perry -p perry-runtime -p perry-stdlib
  • cargo fmt --all -- --check
  • git diff --check
  • ./scripts/check_file_size.sh
  • jq empty test-parity/known_failures.json

Known Limitations

process.threadCpuUsage() keeps Perry's current per-thread CPU split behavior: available thread CPU time is reported as user with system: 0 on supported platforms. This PR adds previous-value support and validation around that existing measurement.

Non-Goals

  • no process.hrtime() changes
  • no UID/GID/umask validation changes
  • no generic EventEmitter refactor
  • no known_failures.json edits

@andrewtdiz
Copy link
Copy Markdown
Contributor Author

Closing this as a duplicate of #3496: #3496. #3496 is the locally verified branch linked from the issue comments for this process validation/readback cut.

@andrewtdiz andrewtdiz closed this May 31, 2026
@andrewtdiz
Copy link
Copy Markdown
Contributor Author

Closing this as a duplicate of #3496, which covers the same process validation/readback issue cluster and is the active PR for #3040, #2927, #3041, and #3049.

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