Skip to content

Fix flaky TestKeepAlive_ConcurrentFramesNoInterleaving - #220

Open
jhrozek wants to merge 1 commit into
mainfrom
worktree-219-flaky
Open

Fix flaky TestKeepAlive_ConcurrentFramesNoInterleaving#220
jhrozek wants to merge 1 commit into
mainfrom
worktree-219-flaky

Conversation

@jhrozek

@jhrozek jhrozek commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • TestKeepAlive_ConcurrentFramesNoInterleaving asserted comments > 0, racing 1600 in-memory writes against a 1ms ticker — on fast machines the writes finish and stopKeepAlive() runs before the ticker ever fires, so comments is 0.
  • Dropped that assertion from the interleaving test (its real guarantee — no split/interleaved frames — is unaffected) and added TestKeepAlive_TickerEmitsComment, which waits deterministically via require.Eventually instead of assuming a tick happens within a fixed window of work.

Fixes #219

Test plan

  • go test -race -count=10 -run TestKeepAlive ./mcpcompat/server/ — all pass
  • task lint

The comments>0 assertion raced 1600 in-memory writes against a 1ms
ticker and lost deterministically on fast machines. Split it into a
separate test that waits for a tick via require.Eventually instead of
tightening the timing.

Fixes #219
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.

TestKeepAlive_ConcurrentFramesNoInterleaving fails deterministically on fast machines (timing-dependent assertion)

1 participant