Skip to content

Fix remote sync RPC double-execution after reconnect#354

Closed
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-detection-9e4b
Closed

Fix remote sync RPC double-execution after reconnect#354
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-detection-9e4b

Conversation

@cursor
Copy link
Copy Markdown
Contributor

@cursor cursor Bot commented May 24, 2026

Summary

Cron critical-bug audit found a correctness issue introduced in Harden Remote Connections (#353).

Bug and impact

Impact: When using a remote runtime, a dropped SSH/RPC connection during a mutating sync call (e.g. sync.connectToBrain, sync.disconnectFromBrain, sync.setPin) could succeed on the server and then run again after auto-reconnect. A second connectToBrain tears down the host (stopHostIfRunning, clearClusterRegistryForViewerJoin) and can disconnect an already-established brain session.

Trigger: Remote project open → sync pairing/connect flow → RPC timeout or channel close after the server handled the first request but before the desktop received the response → pool reconnects and retries the same sync method.

Root cause

RemoteConnectionPool.callSyncForTarget always passed retryOnConnectionError: true to withEntryForTarget, unlike action calls which use shouldRetryRemoteRuntimeAction.

Fix

  • Add an allowlist of read-only sync/model-picker RPCs safe to replay after reconnect.
  • Pass shouldRetryRemoteSyncMethod(method) into callSyncForTarget.
  • Regression test: sync.connectToBrain reconnects but does not invoke the RPC a second time.

Validation

  • npm --prefix apps/desktop run test -- --run src/main/services/remoteRuntime/remoteConnectionPool.test.ts (14 passed)

Related open PRs (not duplicated)

Open in Web View Automation 

Harden Remote Connections (#353) retries every project-scoped sync call
when the SSH/RPC channel drops mid-flight. Mutating methods like
sync.connectToBrain can succeed on the server and then run again on
reconnect, tearing down an established brain session.

Restrict post-reconnect replay to read-only sync and model-picker getters.

Co-authored-by: Arul Sharma <[email protected]>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
ade Ignored Ignored May 24, 2026 4:10am

@arul28
Copy link
Copy Markdown
Owner

arul28 commented May 25, 2026

Consolidated into #356.

@arul28 arul28 closed this May 25, 2026
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