Skip to content

Hold the bridge lock across catalog and live updates - #5

Open
dimondevceo wants to merge 1 commit into
mainfrom
cursor/fix-bridge-sync-race-d9ae
Open

dimondevceo wants to merge 1 commit into
mainfrom
cursor/fix-bridge-sync-race-d9ae

Conversation

@dimondevceo

@dimondevceo dimondevceo commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Race

go test -race fails in internal/httpapi. startBridges starts a goroutine that calls (*bridgeHost).sync immediately and then every 15 seconds. sync reads Server.Plugins and bridgeHost.live. Tests assign srv.Plugins and srv.bridges.live after newTestServer. Startup assigns the catalog after Init. Those writes do not take bridgeHost.mu.

The race detector reports that conflict. The failing tests are TestBridgeSettingsStayOnHost, TestPluginHTTPRoutes, TestPluginScheduleRoute, and TestScreenUsesCatalogAndKeepsCalledNumber. Assertions in those tests were not the failure. The same failure is still on main 46a3152 (v0.9.15).

Fix

sync copies Server.Plugins while holding bridgeHost.mu. live is written only under that lock. SetPlugins publishes the catalog under the same lock. The bridge settings test publishes the catalog and live=false in one critical section, so sync cannot dial a catalog that the test just paused.

Bridge catalog sync is unchanged. Bridge settings still stay on the host. The v0.9.15 bridge-open and per-minute scan billing behavior is untouched. Rebase onto 46a3152 had no conflicts.

Check

go test -race -count=1 ./internal/httpapi/... passed on head 42e2fed after the rebase.

Open in Web Open in Cursor 

@dimondevceo
dimondevceo marked this pull request as ready for review September 30, 2026 02:05
The sync loop reads Server.Plugins and bridgeHost.live while tests and
startup assign them. Take bridgeHost.mu on both sides.

Co-authored-by: DimonDev <dimondevceo@users.noreply.github.com>
@cursor
cursor Bot force-pushed the cursor/fix-bridge-sync-race-d9ae branch from 982863d to 42e2fed Compare September 30, 2026 02:11
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.

2 participants