Skip to content

Fix SSH session WaitGroup race breaking master CI - #307

Merged
dominicletz merged 1 commit into
masterfrom
cursor/fix-ssh-copywg-race-8869
Jul 16, 2026
Merged

Fix SSH session WaitGroup race breaking master CI#307
dominicletz merged 1 commit into
masterfrom
cursor/fix-ssh-copywg-race-8869

Conversation

@dominicletz

@dominicletz dominicletz commented Jul 16, 2026

Copy link
Copy Markdown
Member

Summary

Master CI is still red after #306. The retry-test race is fixed, but the latest master run fails on macos-15-intel with a different data race in the embedded SSH session path.

Root cause

In handleSSHSessionStart, both proxySSHProcessIO and waitForProcess were started as goroutines:

  • proxySSHProcessIO calls copyWG.Add(1) for stdout/stderr copy goroutines
  • waitForProcess calls copyWG.Wait() after the process exits

sync.WaitGroup forbids concurrent Add and Wait, which -race catches. The race also closed the SSH channel before output was fully copied, causing TestEmbeddedSSHServiceExecCurrentUser to see empty output.

Fix

Run proxySSHProcessIO synchronously so all copyWG.Add calls complete before waitForProcess is started. Copy I/O still runs in background goroutines.

CI context

Commit Failure
033d081 backoff Ubuntu: race in client_manager_retry_test.go (fixed by #306)
d8c9d09 #306 merge macOS-15-intel: race in ssh_service.go (this PR)

Ubuntu/macOS-14/ARM already passed on the latest master run; Windows was cancelled due to fail-fast.

Verification

go test -tags patch_runtime -race -count=50 -run 'TestEmbeddedSSHServiceExecCurrentUser$' ./rpc/
go test -tags patch_runtime -race -count=5 -run 'TestEmbeddedSSH' ./rpc/
go test -tags patch_runtime -race -count=3 ./rpc/

All passed locally after this change.

Open in Web Open in Cursor 

proxySSHProcessIO was started in a goroutine alongside waitForProcess,
so copyWG.Add raced with copyWG.Wait. Run the proxy setup synchronously
so Adds complete before Wait, matching sync.WaitGroup rules.

This was failing master CI on macos-15-intel in
TestEmbeddedSSHServiceExecCurrentUser after the retry-test race fix.

Co-authored-by: Dominic Letz <dominicletz@users.noreply.github.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modifies rpc/ssh_service.go to run proxySSHProcessIO synchronously instead of in a goroutine. This ensures that all copyWG.Add calls complete before waitForProcess calls Wait, preventing a potential data race. Relevant explanatory comments have also been added. There are no review comments, so I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@dominicletz
dominicletz marked this pull request as ready for review July 16, 2026 17:06
@dominicletz
dominicletz merged commit 7cdc403 into master Jul 16, 2026
18 checks passed
@dominicletz
dominicletz deleted the cursor/fix-ssh-copywg-race-8869 branch July 16, 2026 17:06
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