Repository navigation
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Comment |
This was referenced Oct 24, 2026
subscribe(), unsubscribe() and unsubscribe_all() are called while connect() runs, often from another thread, but they changed scheduled_subs and schedule_resub with no lock. The receive loop read scheduled_subs, awaited the subscribe and unsubscribe sends, and then copied scheduled_subs into subs and cleared schedule_resub. A change made during either await was copied into subs without being sent, and its schedule_resub was cleared, so it was never sent. The server then streamed different topics from the ones requested, while subs said everything was sent. Guard both attributes with a lock, which the three methods take for their whole body. The receive loop now copies scheduled_subs and clears schedule_resub under the lock, sends the difference from that copy, and records the copy in subs. A change made during the sends sets schedule_resub again and goes out on the next turn. Code that changes scheduled_subs itself and sets schedule_resub keeps working: the loop still checks the flag on every turn.
chipkent
force-pushed
the
fix/ws-keep-subscriptions-on-reconnect
branch
from
October 24, 2026 14:54
4c8e194 to
1f2d987
Compare
chipkent
force-pushed
the
fix/ws-thread-safe-subscribe
branch
from
October 24, 2026 14:54
a444d2c to
90a5fb6
Compare
This was referenced Oct 24, 2026
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.
Fixes #<issue: F1a-race>
Builds on #19: its test uses the mock server's
inbox.subscribe(),unsubscribe()andunsubscribe_all()are called whileconnect()runs, often from another thread, with no lock. The receive loop readscheduled_subs, awaited two sends, then copiedscheduled_subsintosubsand clearedschedule_resub. A change made during either await was recorded as sent but never sent, so the server streamed different topics from the ones requested.scheduled_subsandschedule_resub. The three methods hold it for their whole body, through a small decorator, so their code is not re-indented.scheduled_subsand clearsschedule_resubunder the lock, sends from the copy, and records only the copy insubs. A change made during the sends goes out on the next turn.scheduled_subsitself and setsschedule_resub = Truestill works.Tests
test_threads.pymakes a change from inside the subscribe send, the window another thread can hit, and checks that the server receives it. It fails every time without the fix.make testandmake lintpass on 3.10 and 3.14.