Skip to content

test(engine): run the non-PNG probe test on a fake clock - #6907

Merged
miguel-heygen merged 1 commit into
mainfrom
fix/beginframe-probe-test-clock
Nov 1, 2026
Merged

miguel-heygen merged 1 commit into
mainfrom
fix/beginframe-probe-test-clock

Conversation

@miguel-heygen

Copy link
Copy Markdown
Collaborator

What

The test "reports frames that are not a PNG as unsupported, not as a slow start" ran the probe against a real 120 ms deadline. On a loaded Windows runner the event loop stalled past it, the probe reported a slow start (timedOut=true) and the merge queue dropped an unrelated PR.

It now runs on fake timers and advances the clock by hand, so the result no longer depends on how busy the machine is. No production code changes.

fails without the fix: browserManager.test.ts › "reports frames that are not a PNG as unsupported, not as a slow start" (with the old test, a 150 ms stall in the mocked CDP call gives expected true to be false)

Tests

That test passes 3 runs in a row on Linux.

Size

Under 100 changed lines.

@heygengenesis heygengenesis Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving at 12b3c6b9. I found no blockers.

  • Root cause matches. probeBeginFrameSupport reads Date.now() against a 120 ms deadline. Under a real stall, awaitBeforeDeadline sees remainingMs <= 0 and throws BeginFrameProbeTimeout, so the result is timedOut=true. That timeout path wins over the loop's normal non-PNG exit, which throws a plain Error.
  • The fix works. Vitest 4 fake timers mock Date as well as setTimeout, so the deadline only moves when the test advances the clock. Advancing 200 ms (more than the 120 ms deadline) lets the loop hit its Date.now() + 10 >= deadline break and end with the 8-byte non-PNG Error. pending settles because page.close() resolves at once, and the finally puts real timers back.
  • Fails without the fix (checked). I made the mocked send stall for 150 ms on every call:
    • Old test: expected true to be false, which matches the line in the PR body.
    • New test: passes. I used Atomics.wait, because a busy-wait on Date.now/hrtime spins forever under fake timers.
  • Suite still green. The unchanged test file has 117/117 passing. The BeginFrame capability probe block passed 3/3 runs on Linux.

Not blocking: the other probe tests in this block still use real short deadlines. They look safe from stalls: the "empty screenshot" test expects timedOut=true, and a stall only pushes it that way. If one of them flakes later, it can get the same fake-clock change.

@miguel-heygen
miguel-heygen added this pull request to the merge queue Nov 1, 2026
Merged via the queue into main with commit ef0007b Nov 1, 2026
112 of 114 checks passed
@miguel-heygen
miguel-heygen deleted the fix/beginframe-probe-test-clock branch November 1, 2026 00:32
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