fix(backend): add context cancellation to between-run listener goroutines#1065
fix(backend): add context cancellation to between-run listener goroutines#1065Gkrumbach07 wants to merge 1 commit intomainfrom
Conversation
…ines
The between-run listener goroutine could leak if a runner pod died
without closing the TCP connection (e.g., OOM kill). The goroutine
would block forever on ReadString with no way to cancel it.
Fix:
- Store context.CancelFunc in betweenRunListeners map instead of struct{}
- Use http.NewRequestWithContext so context cancellation closes the
HTTP response body and unblocks ReadString
- Replace time.Sleep with select{} on ctx.Done for interruptible backoff
- cleanupStaleSessions calls the CancelFunc to terminate the goroutine
- Check ctx.Err() at retry boundaries to exit promptly on cancellation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughRefactors between-run listener lifecycle management in the websocket proxy by replacing sentinel values with Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Review Queue Status
Action needed: Fix CodeQL failure
|
Summary
context.Contextto between-run listener goroutines for clean cancellationChanges
context.CancelFuncinbetweenRunListenersmap (wasstruct{})http.NewRequestWithContextso context cancellation closes the HTTP response body and unblocksReadStringtime.Sleepwithselect{}onctx.Donefor interruptible backoffcleanupStaleSessionscalls theCancelFuncto terminate the goroutinectx.Err()at retry boundaries to exit promptly on cancellationWhy
Without context cancellation, if a runner pod dies (e.g., OOM kill) without sending EOF, the listener goroutine blocks forever on
ReadString('\n'). Each leaked goroutine holds ~8KB stack + one open TCP connection. Thesync.Mapentry stays, preventing new listeners for that session.Test plan
go build ./...passes🤖 Generated with Claude Code