Skip to content

feat(timers): implement node:timers/promises setTimeout/setImmediate (#1213)#1449

Merged
proggeramlug merged 1 commit into
mainfrom
feat/timers-parity-1213
May 23, 2026
Merged

feat(timers): implement node:timers/promises setTimeout/setImmediate (#1213)#1449
proggeramlug merged 1 commit into
mainfrom
feat/timers-parity-1213

Conversation

@proggeramlug
Copy link
Copy Markdown
Contributor

Summary

node:timers/promises setTimeout(delay, value?) and setImmediate(value?) were unimplemented stubs that threw '… is not yet implemented', so await setTimeout(ms) / await setTimeout(ms, value) never resolved (part of the #1213 node:timers parity tracker / #793).

Both are now wired to the existing promise-returning timer primitive js_set_timeout_value, returning a Promise that resolves with value (or undefined). setTimeout is registered with arity 2 so the closure dispatch pads a missing value arg with undefined; setImmediate resolves on a later turn (0-delay). No closure synthesis needed — composes the existing tested timer→promise plumbing.

Test

  • Flips test_parity_timers_promises to PASS (removed from known_failures.json).
  • Flips node-suite/timers/promises/shadowed-global-fast-paths to PASS — removed the stale test-parity/expected/ snapshot that recorded the old stub error, so it now compares against live Node (both produce setTimeout resolved object {"a":1} / setImmediate resolved object {"b":2}).
  • Verified value + no-value forms match Node:
await setTimeout(10)        // resolves undefined
await setTimeout(10, 'VAL') // resolves 'VAL'
await setImmediate('iv')    // resolves 'iv'

Remaining #1213 sub-gaps (separate follow-ups): setInterval async-iterator, scheduler/AbortSignal paths, numeric timer clears, and timer-callback this binding.

Refs #1213.

…1213)

setTimeout(delay, value?) and setImmediate(value?) from node:timers/promises
were unimplemented stubs that threw 'not yet implemented'. Wire them to the
existing promise-returning timer primitive js_set_timeout_value so they
return a Promise that resolves with value (or undefined). setTimeout takes
(delay, value); registering the export arity makes the closure dispatch pad
a missing value with undefined. setImmediate resolves with value on a later
turn (0-delay).

Flips test_parity_timers_promises to PASS (removed from known_failures) and
node-suite/timers/promises/shadowed-global-fast-paths (the stale expected-
output snapshot recording the stub error is removed so it compares against
live Node). setInterval/scheduler async-iterator + AbortSignal paths remain
(other #1213 sub-gaps).
@proggeramlug proggeramlug merged commit 395b1e2 into main May 23, 2026
9 checks passed
@proggeramlug proggeramlug deleted the feat/timers-parity-1213 branch May 23, 2026 01:48
proggeramlug added a commit that referenced this pull request May 23, 2026
…es (#1458)

Rolls up 22 PRs that merged to main post-v0.5.1025 without per-PR
version bumps.

- node:timers epic (#1213, 6 PRs #1449-#1455): node:timers/promises
  setTimeout/setImmediate, numeric-id clear*, namespace import, ref()
  typeof, Symbol.dispose, global setImmediate/clearImmediate.
- node:perf_hooks fan-out (10 PRs across #1320 #1327 #1337-#1340
  #1388-#1390 #1403): typeof methods, performance singleton identity,
  nodeTiming, toJSON, clearResourceTimings, structured-clone detail,
  observer arg + buffered + throw cases.
- node:json lazy-tape closes #1424 (#1447) — JSON.parse reviver on
  lazy-tape arrays no longer SIGSEGVs (test un-skip-listed).
- #1448 console.log/util.inspect on lazy-tape arrays materialises
  before formatting.
- #1429 GC unsafe-zone guards for fastify/hyper handlers.
- #1341 codegen: Any-typed .includes()/.indexOf() dynamic dispatch.
- #1370 perry/ui web driver debug noise dropped.

#1423 (AsyncLocalStorage .enterWith/.exit) remains skip-listed.
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