test(desktop): stop the focus-resume test racing a fixed 10ms sleep - #6278
Open
mfethe1 wants to merge 1 commit into
Open
test(desktop): stop the focus-resume test racing a fixed 10ms sleep#6278mfethe1 wants to merge 1 commit into
mfethe1 wants to merge 1 commit into
Conversation
`focused polling pauses on blur and resumes after activation yields` waited a single `setTimeout(…, 10)` for the resume to land, then asserted the observed sequence. The resume is a three-hop chain — `scheduleAfterForegroundReady` does `setTimeout(0)` → `requestAnimationFrame` → `setTimeout(0)` — and jsdom fires rAF on a ~16ms cadence, so 10ms could never reliably cover it. The test passed on an idle machine and failed whenever the event loop was contended, which is exactly what a full `pnpm test` run does. It now polls until the resume is observed (2s ceiling) instead of guessing a duration. The assertion is unchanged and just as strict: the same `assert.deepEqual(observed, [1_000, false, 1_000])` still runs, so a resume that never fires still fails, with the same diff. Measured on x86_64-pc-windows-msvc, running the file 12x with six busy loops saturating the CPU: - before: 8 passed, 4 failed - after: 12 passed, 0 failed Full desktop suite with the fix: `pnpm test` 5037 passed, 0 failed (it had been reporting 5036/1 on this test); `pnpm check` exit 0. Signed-off-by: Michael Feth <michael@jira-flow.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
test(desktop): stop the focus-resume test racing a fixed 10ms sleep
focused polling pauses on blur and resumes after activation yieldswaited asingle
setTimeout(…, 10)for the resume to land, then asserted the observedsequence. The resume is a three-hop chain —
scheduleAfterForegroundReadydoessetTimeout(0)→requestAnimationFrame→setTimeout(0)— and jsdom firesrAF on a ~16ms cadence, so 10ms could never reliably cover it. The test passed
on an idle machine and failed whenever the event loop was contended, which is
exactly what a full
pnpm testrun does.It now polls until the resume is observed (2s ceiling) instead of guessing a
duration. The assertion is unchanged and just as strict: the same
assert.deepEqual(observed, [1_000, false, 1_000])still runs, so a resume thatnever fires still fails, with the same diff.
Measured on x86_64-pc-windows-msvc, running the file 12x with six busy loops
saturating the CPU:
Full desktop suite with the fix:
pnpm test5037 passed, 0 failed (it had beenreporting 5036/1 on this test);
pnpm checkexit 0.