Repository navigation
fix(runner): close the code-server teardown gaps left by #449 - #600
Conversation
The reaper kills the leader's process group once the leader is reaped, so neither the context's leader-only kill in the spawn window nor a leader that exits on its own leaves group members running. Stop leaves the manager in a final stopped status, which StartAsync and a racing doStart cannot move it out of. IsRunning and the started flag that could disagree with Status are removed; nothing outside tests read them.
There was a problem hiding this comment.
🟡 Changes recommended
Moderate review findings require tests that exercise the actual startup failure and readiness race paths.
1 open issue
What changed in this PR
This pull request closes code-server teardown gaps by cleaning up entire process groups after leader exit and making the manager’s stopped state terminal during concurrent startup operations.
Changes:
- Kill remaining process-group members after the leader is reaped.
- Prevent startup status updates from overwriting
stopped. - Remove redundant running-state tracking.
- Add Unix regression tests for teardown and status transitions.
- Review identified missing coverage for startup failure and readiness races.
| File | Description |
|---|---|
pkg/runner/editor.go |
Implements post-reap process-group cleanup and terminal stopped-state handling. |
pkg/runner/editor_unix_test.go |
Adds and updates Unix teardown and manager-state regression tests. |
Review effort: Lite
There was a problem hiding this comment.
WALL-D review: Approval withheld · head 7681fc0
Code review result: Human approval required · head 7681fc0
Review summary
A maintainer will review this PR.
Re-review requests and limits
WALL-D reviews a PR opened ready after this rule took effect once on its own. After that it reviews only on request: comment @alpacax-wall-d review or mark a draft ready for review, up to 5 times per PR including the first review. A re-review reads only the lines changed since the last review, and from the second re-review on only P1 findings block approval. Answering the product review's questions reviews only the product side again.
- fix issues raised in review
|
@alpacax-wall-d review |
|
Reviewed ec6b057: #600 (review) |

Fixes #454
Why
The review of #449 left three ways code-server teardown could still go wrong. A
Stopin the spawn window, or a leader that died on its own, left the rest of the process group running. A stopped manager could still reportready. The fix the issue proposed for the spawn window (a context check after the process is published) does not close it:exec.CommandContextkills the leader alone on cancel, and once that kill is reaped the secondStoptakes the "already reaped" path and signals nothing.What changed
codeServerProcesshandle. Its reaper waits for the leader to exit without collecting it (waitidwithWNOWAITon Linux, a kqueueNOTE_EXITon macOS), SIGKILLs the process group, and only then reaps the leader.Stop's SIGTERM and its SIGKILL after the grace period take the same lock, so every signal to the group is sent while the leader is still unreaped. This covers every way the leader dies: a crash, the context's kill, or a SIGTERM its children outlive.Stopsets a finalstoppedstatus, and thedoStartandStartAsyncstatus writes cannot move a manager out of it.doStart's own failure path usesstopProcess, which leaves the status alone so the start error still reaches the health check.IsRunningand thestartedflag are removed. Only tests read them, and they could disagree withStatus.Scope
ready. That predates this PR and is not in it.kqueuefails withEMFILE), the reaper falls back to a plainWait, andStopkills the leader through its handle only. The group is not swept on that path.Tradeoffs
idle, which the issue suggested, would let a health check racingTunnelClient.ClosecallStartAsync, which leaves a manager whoseStartalready ran stuck instarting. The newstoppedvalue maps to HTTP 500 through the existing default branch, which the web editor already treats as an error.Stopgets SIGKILL once the leader exits, so it no longer gets the rest of the grace period.Blast radius
This touches only the code-server editor tunnel teardown. Two security reviews of the kill path found no issue that blocks the merge. The fixes for what they did find are in this PR: a start error that was lost, and a
Stopthat could block when the exit cannot be watched.Verification
readyafterStop.go test -race ./pkg/runnerpasses on macOS and on Linux (golang:1.26in Docker), and the teardown tests pass 30 times in a row on both.go vetpasses withGOOS=windows, andcmd/alpamonbuilds for every target in.goreleaser.yaml.