Skip to content

fix(runners): a drain reaches the runner as GOAWAY, not a closed session (#278) - #833

Merged
aixle-com[bot] merged 1 commit into
developfrom
feature/runner-drain-goaway-order
Nov 23, 2026
Merged

aixle-com[bot] merged 1 commit into
developfrom
feature/runner-drain-goaway-order

Conversation

@NOX73

@NOX73 NOX73 commented Nov 21, 2026

Copy link
Copy Markdown
Collaborator

Fixes #278: a drain could reach the runner as a closed session instead of GOAWAY.

Cause

The runner's Session read the relay's GOAWAY and then, with no stream open, the relay's 1000 "drained" close. If both were read before the caller reached Accept, Accept saw s.err first and returned ErrSessionClosed, hiding the received GOAWAY. The relay sends GOAWAY first and closes only after the writer drained, so the server side is correct; the loss is in the client session's check order.

Fix

  • runner/protocol/tunnel/session.go: Accept returns ErrGoAway when GOAWAY was received and the session ended because the relay closed the connection with 1000. Other endings (close without GOAWAY, other codes, heartbeat, local Close) keep their errors.
  • runner/protocol/PROTOCOL.md §8.8: states the rule for GOAWAY followed by a close.

Runner behaviour (item 3)

runner/internal/tunnel/manager.go already treats GOAWAY and a relay close with 1000/1001 the same way (relayClosedNormally -> outcomeGoAway): reconnect after up to 2 s of jitter, no backoff growth (§3.2). So a drained runner reconnected correctly in both cases; only Accept's error (and the flaky test) was wrong. A drain does not take the lost-connection path.

Tests

  • TestRunnerAcceptReportsGoAwayWhenTheCloseFollowsIt (fails on develop with the exact CI message, passes after) and TestRunnerAcceptReportsAClosedSessionWhenTheCloseHasNoGoAway.
  • go test -race -count=5000 -cpu 1,2,4 -run TestDrainSendsGoAwayAndStopsTakingConnections ./internal/relay/: 5085 failures in 15000 runs on develop, 0 in 15000 with the fix. (-count=300 on develop did not reproduce.)
  • go vet and go test -race ./... pass in runner/ and runner-relay/.

@aixle-com aixle-com Bot changed the title runner tunnel: a drain reaches the runner as GOAWAY, not a closed session (#278) fix(runners): a drain reaches the runner as GOAWAY, not a closed session (#278) Nov 21, 2026

@aixle-com aixle-com 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.

Reviewed head 8fec8f1. The fix is in the right place: Accept is the only call that hides a GOAWAY behind a close, serve.go already treats ErrGoAway as the drain path, and §8.8 states the rule. The two tests cover the GOAWAY+1000 case and the close without GOAWAY. No review remarks requiring PR comments.

@aixle-com
aixle-com Bot merged commit 7887666 into develop Nov 23, 2026
18 of 19 checks passed
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.

1 participant