Skip to content

test(threads): await completion before comparing subscribers - #567

Merged
nixuuu merged 1 commit into
devfrom
fix/late-abort-subscription-race
Nov 12, 2026
Merged

nixuuu merged 1 commit into
devfrom
fix/late-abort-subscription-race

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 12, 2026

Copy link
Copy Markdown
Member

The late-cleanup integration test compared two live readers' sequence numbers as soon as each contained the answer text. The worker publishes that item before turnFinished, so an independently scheduled reader can already be at the final sequence while the other still has only the answer. Run 43196187406, attempt 2, job Tests (4/4) failed at thread-multiclient.test.ts:169 with Expected: 4n, Received: 3n; both answer-presence waits had succeeded.

Wait for completion of the specific sent turn and sequence convergence before comparing readers. Make the timing difference deterministic: publish an in-progress answer through the real scripted worker, pause the desktop reader after applying it, let the paired phone consume completion, assert that the desktop legitimately lags, then release it and verify convergence. Both abort/return cleanup orderings still run over real gateway/worker and paired-phone transports. The gate is released in cleanup, and no production hook or timed sleep is added.

This test uses the legacy local watch path (sequence is unset), not #541's sequence-resume reader. The premature equality assertion dates to #350; the captured failure does not show shared-subscription teardown. There are no production changes and no Fixes: link. The existing 20 repeated move tests remain unchanged.

Validation: changed-file oxfmt/oxlint and git diff --check passed. No local tests, installs, typechecks or builds while the host measurement is running. All required checks and two consecutive complete CI passes on the final head are pending remotely.

Related: #350, #541, #566

Answer text can arrive before turnFinished, so independently scheduled desktop and phone readers can legitimately have different lastSeq values. Hold the desktop after its answer, let the phone finish, then release it and wait for the specific turn and sequence to converge. Preserve both late cleanup orderings.

Related: #350, #541, #566
@nixuuu
nixuuu marked this pull request as ready for review November 12, 2026 10:48
@nixuuu
nixuuu merged commit 4f6ae41 into dev Nov 12, 2026
18 checks passed
@nixuuu
nixuuu deleted the fix/late-abort-subscription-race branch November 12, 2026 10:49
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