Skip to content

Auto-close test: stop two cases racing their own timers on a slow runner - #321

Closed
shakibbinkabir wants to merge 1 commit into
Louis-CFM:mainfrom
shakibbinkabir:fix-flaky-auto-close-test
Closed

shakibbinkabir wants to merge 1 commit into
Louis-CFM:mainfrom
shakibbinkabir:fix-flaky-auto-close-test

Conversation

@shakibbinkabir

Copy link
Copy Markdown
Contributor

"Test auto-close timing" fails now and then on PRs that do not touch the state machine: at line 27 on windows-catch-up (#307) and at line 54 on mochi-colours (#320). That is 2 of the last 17 finished Build runs.

Cause

Two cases sleep for a fixed time and then assert that a pending timer has not fired yet:

Case Sleep Timer that must not have fired Slack
"Increasing the delay…" (line 27) 100 ms 250 ms 150 ms
"Greeting timing…" (line 54) 50 ms 150 ms 100 ms

When the runner stalls for longer than the slack, the timer fires first and the precondition traps.

Fix

Both timers are now a full second out, and the two waitForCompact calls that follow get 3 s instead of 1 s. What each case checks is unchanged: the old 50 ms timer must not close the island, and the 10 ms auto-close preference must not cut the greeting short. Only the test file changes, and it takes about 1.6 s longer.

Measurements

On a macos-latest runner on my fork, both versions compiled the way scripts/test-auto-close.sh does:

Old test New test
Idle, 10 runs 0 failed 0 failed
9 busy loops on 3 cores, 40 runs 0 failed 0 failed
Process frozen 200 ms out of every 500 ms (SIGSTOP/SIGCONT), 30 runs 21 failed: 16 at line 27, 5 at line 54 0 failed

Plain CPU load did not reproduce it; freezing the process did, at the same two lines CI failed on. The freeze is my model of a stalled runner, not something I observed on the failing runs.

🤖 Generated with Claude Code

Two cases sleep for a fixed time and then assert that a pending timer has not
fired yet, with 150 ms and 100 ms to spare. On a busy macOS runner the sleep
runs long, the timer fires first and the precondition traps: line 27 on the
windows-catch-up PR, line 54 on mochi-colours, neither of which touches the
state machine.

Both timers are now a full second out, so the sleeps only have to outlast what
they are there to outlast. The test takes about 1.6 s longer.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@shakibbinkabir

Copy link
Copy Markdown
Contributor Author

Folded into #365 as its first commit (df9b63a), unchanged, so everything is in one place. It can still be taken on its own from there.

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