ReviewOS

home-lang/home

Bun parity: complete setTimeout lifecycle and handle semantics

#387
Closed chris opened this 10 days ago ·
10 days ago

Tracks Bun corpus frontier position 4194: js/web/timers/setTimeout.test.js.

Initial exact result: 0 pass, 1 fail, 1 unsupported. The first failure is timer-handle lifecycle accounting: after setTimeout(() => {}, 0), the test expects zero active handles but observes one. Scope is the complete upstream timeout contract, including the unsupported construct, clear/ref/unref behavior, callback arguments, coercion, lifecycle cleanup, and permanent regressions with actionable errors where applicable.

Parent: #66 Predecessor: #386

10 days ago

Completed and pushed in 57d6dc8 (fix(timers): complete timeout lifecycle semantics).

Verification:

  • Upstream js/web/timers/setTimeout.test.js: 30 pass, 1 intentional upstream todo, 0 fail, 0 unsupported.
  • Permanent web timer regression: 6 pass, including minimum-delay ordering, post-fire refresh generations, clear finality, callback receiver identity, protected Timeout cleanup, and Date-based Bun.sleep deadlines.
  • Full zig build --cache-dir /private/tmp/home-zig-abi-cache: pass.
  • Formatting and whitespace checks: pass.

The timer scheduler now invalidates stale generations, permits refresh after firing but not after clear, tracks active Timeout protection accurately, binds callbacks to their handles, clamps real timeout delays consistently, and advances the shared performance clock for Bun.sleep(Date). Parent: #66. Predecessor: #386.

Sign in to comment on this issue.