Skip to content

Fix race between integrated auto-start and manual connect leaving a stale subscriber-less proxy - #182

Merged
amorfinv merged 2 commits into
mainfrom
fix/auto-start-manual-connect-race
Aug 19, 2026
Merged

Fix race between integrated auto-start and manual connect leaving a stale subscriber-less proxy#182
amorfinv merged 2 commits into
mainfrom
fix/auto-start-manual-connect-race

Conversation

@amorfinv

Copy link
Copy Markdown
Collaborator

Summary

Fixes a race between the integrated build's BlueSky auto-start and the manual /api/server/config connect 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_subscribers resolved the global proxy), whose data-flow timeout later broadcast a bogus disconnect and blanked the map while the real proxy streamed fine.

Changes

  • Core (WebATM/proxy, WebATM/server/routes.py): new shared connect_lock serializes the swap-and-connect of the global proxy; /api/server/config holds it around its tear-down/replace/connect sequence. register_subscribers now accepts the proxy to attach to explicitly (falling back to the global), so subscribers always land on the client that was just started.
  • Integrated (webatm_integrated/auto_start.py): the connect step runs under the shared connect_lock and 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.proxy and are consumed (with injectable test seams) by the integrated package.

🤖 Generated with Claude Code

amorfinv and others added 2 commits August 19, 2026 20:55
… 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>
@amorfinv
amorfinv merged commit 8ffe8c6 into main Aug 19, 2026
2 checks passed
@amorfinv
amorfinv deleted the fix/auto-start-manual-connect-race branch August 19, 2026 18:57
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