Skip to content

test: replace fixed-delay sleep-then-assert races in subscriptionReplay - #1219

Merged
kriszyp merged 1 commit into
mainfrom
claude/fix-1138-subscription-replay
Jun 10, 2026
Merged

test: replace fixed-delay sleep-then-assert races in subscriptionReplay#1219
kriszyp merged 1 commit into
mainfrom
claude/fix-1138-subscription-replay

Conversation

@claude

@claude claude Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Converts the racy await delay(N); assert(<async side effect happened>) patterns in unitTests/resources/subscriptionReplay.test.js to condition-waits using the shared waitFor() helper (unitTests/waitFor.js). These fixed wall-clock waits race loaded CI runners — the root flakiness pattern tracked in the umbrella issue #1138 (the same shape behind #19's load-dependent failures).

Six sites converted:

  • race conditions > FIRST-subscription-on-fresh-DB ... — wait until all 200 in-flight ids delivered
  • race conditions > startTime: subscribe while writes are in flight ... — wait until all 200 in-flight ids delivered
  • race conditions > !omitCurrent: subscribe-then-write on a fresh database ... — wait for the single post-subscribe event (kept the delay(50) that models production "subscribe established, then live write" timing)
  • edge cases > count: empty initial state, then live commits ... — wait for 5 live events
  • edge cases > count: only other-table records exist ... — wait for our 3 live events
  • edge cases > whenNextTransaction resolves on commit ... — wait for the waiter to resolve (textbook delay; assert(resolved) case)

Legitimate sleeps that model elapsed time (the collect() quiet-period drain, brief cursor-advance gaps, the subscribe-then-write production-timing gap) are intentionally left as fixed delay().

No production code changed — test surface only.

Test plan

  • npm run lint (oxlint) clean
  • npm run format:check — modified file clean (only untracked .harper-skills/ flagged)
  • npm run build passes
  • npm run test:unit -- unitTests/resources/subscriptionReplay.test.js — 27 passing, 9 pending (count-branch tests are LMDB-only)
  • LMDB run of the two count-branch converts (sandbox blocked the HARPER_STORAGE_ENGINE=lmdb invocation locally; the converts are structurally identical to the rocksdb-running ones that pass)

Closes #1138

🤖 Generated with Claude Code

Convert the "await delay(N); assert(side effect landed)" timing races in
unitTests/resources/subscriptionReplay.test.js to condition-waits via the
shared waitFor() helper. These fixed waits raced loaded CI runners and are
an instance of the flakiness tracked in #1138. Legitimate sleeps that model
elapsed time (subscribe-then-write gaps, collect() quiet periods) are left
as-is.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@claude

claude Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

Reviewed; no blockers found.

@kriszyp
kriszyp merged commit 53653a7 into main Jun 10, 2026
36 of 37 checks passed
@kriszyp
kriszyp deleted the claude/fix-1138-subscription-replay branch June 10, 2026 22:09
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.

Replace fixed-delay 'sleep-then-assert' timing races in unit tests (umbrella)

2 participants