Fix race between integrated auto-start and manual connect leaving a stale subscriber-less proxy - #182
Merged
Merged
Conversation
… on an explicit proxy Add a shared connect_lock to WebATM.proxy and hold it in /api/server/config around the tear-down/replace/connect sequence, so a concurrent connector can never revive the proxy this request is replacing. register_subscribers now takes the proxy to attach to (falling back to the global), so subscribers always land on the client that was just started even if the global is swapped concurrently. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… the proxy The port wait can span many seconds on a cold start; if the user connects manually meanwhile, /api/server/config replaces the global proxy and closes the boot-time one auto-start captured. Connecting it anyway left a second, subscriber-less ZMQ client alive whose data-flow timeout later broadcast a bogus disconnect and blanked the map. Auto-start now runs its connect step under the shared connect_lock, re-checks the global proxy is still its own, and stands down if a manual connect took over. Subscribers are registered on the connected proxy explicitly. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Summary
Fixes a race between the integrated build's BlueSky auto-start and the manual
/api/server/configconnect route. Auto-start's port wait can span many seconds on a cold start; if the user connected manually during that window, the route replaced (and closed) the boot-time proxy auto-start had captured — but auto-start would then connect the stale proxy anyway. That left a second ZMQ client alive with no subscribers (register_subscribersresolved the global proxy), whose data-flow timeout later broadcast a bogus disconnect and blanked the map while the real proxy streamed fine.Changes
WebATM/proxy,WebATM/server/routes.py): new sharedconnect_lockserializes the swap-and-connect of the global proxy;/api/server/configholds it around its tear-down/replace/connect sequence.register_subscribersnow accepts the proxy to attach to explicitly (falling back to the global), so subscribers always land on the client that was just started.webatm_integrated/auto_start.py): the connect step runs under the sharedconnect_lockand re-checks that the global proxy is still the one it captured at boot; if a manual connect took over, auto-start stands down instead of reviving the stale proxy.The dependency arrow stays integrated → core: the lock and getter live in
WebATM.proxyand are consumed (with injectable test seams) by the integrated package.🤖 Generated with Claude Code