Skip to content

[codex] reject timers promises validation errors#4351

Draft
andrewtdiz wants to merge 1 commit into
PerryTS:mainfrom
andrewtdiz:codex/node-timers-promises-validation-rejections
Draft

[codex] reject timers promises validation errors#4351
andrewtdiz wants to merge 1 commit into
PerryTS:mainfrom
andrewtdiz:codex/node-timers-promises-validation-rejections

Conversation

@andrewtdiz
Copy link
Copy Markdown
Contributor

Summary

  • Return rejected promises for invalid delay, options, and options.ref validation in node:timers/promises promise helpers.
  • Preserve Node's setInterval() shape by returning an async iterator and rejecting the first .next() promise for validation errors.
  • Extend the timers/promises parity fixture to cover invalid interval delay/options through .next().

Root Cause

Perry already built Node-shaped TypeError [ERR_INVALID_ARG_TYPE] values for these validators, but it threw them synchronously from the native helper before returning a promise or iterator. Node returns rejected promises for setTimeout, setImmediate, and scheduler.wait, and defers setInterval validation to the iterator's .next() promise.

Validation

  • cargo build -p perry -p perry-runtime -p perry-stdlib
  • cargo test -p perry-runtime timers_promises --lib
  • cargo fmt --all -- --check
  • git diff --check
  • Node/Perry diff: test-parity/node-suite/timers/promises/delay-options-validation.ts
  • Node/Perry diff: test-parity/node-suite/timers/promises/ref-option-validation.ts
  • Node/Perry smoke diffs: imports.ts, scheduler-not-callable.ts, set-immediate-signal.ts

Refs #2013.

@andrewtdiz
Copy link
Copy Markdown
Contributor Author

Validated this exact branch (993b37a6f) after comparing with the later duplicate #4354. This branch is the better one to keep because its invalid setInterval() path preserves Node's normal iterator surface and one-shot rejection behavior (next() rejects once, then returns done).

Additional validation run:

  • cargo fmt --all -- --check
  • git diff --check HEAD^..HEAD
  • ./scripts/check_file_size.sh
  • CARGO_TARGET_DIR=/root/perry-worktrees/perry-node-timers-promises-validation/target cargo check -p perry-runtime
  • timers validation subset: 4 pass, 0 fail, 0 compile fail (parity_report_20260604_063703.json)
  • full timers module: 90 pass, 0 fail, 0 compile fail (parity_report_20260604_063720.json)

I am closing #4354 as a duplicate in favor of this PR.

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.

1 participant