Repository navigation
server: preserve websocket close code when proxying to outposts - #26090
Merged
BeryJu merged 3 commits intoSep 14, 2026
Merged
Conversation
The websocket proxy that bridges outpost connections to the gunicorn/uvicorn backend replaced every relayed close frame with a code-less close (`Message::Close(None)`), discarding the status code and reason from the peer. When a web worker is recycled (routinely, via web.max_requests) or restarted on upgrade, uvicorn closes the outpost websocket gracefully with 1012 (service restart). Because the proxy relayed `Close(None)`, the outpost instead received a close frame with no status code, which surfaces as `websocket: close 1005 (no status)` and is logged at warning level - indistinguishable from a genuine fault, so a healthy deployment warns on every recycle and trips outpost-disconnect alerting. The reverse direction stripped the outpost's own close code too. Relay the received close frame verbatim in both directions so the peer sees the real close code and reason. The tail-of-stream case (peer closes without sending a Close frame) still sends `Close(None)`, which is correct. Co-Authored-By: Claude Opus 4.8 <[email protected]>
✅ Deploy Preview for authentik-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Signed-off-by: Jens Langhammer <[email protected]>
BeryJu
approved these changes
Sep 14, 2026
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #26090 +/- ##
==========================================
- Coverage 91.88% 91.84% -0.04%
==========================================
Files 1171 1171
Lines 75613 75615 +2
Branches 4054 4056 +2
==========================================
- Hits 69475 69452 -23
- Misses 6096 6121 +25
Partials 42 42
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
Contributor
|
🍒 Cherry-pick to |
BeryJu
added a commit
that referenced
this pull request
Sep 14, 2026
…ry-pick #26090 to version-2026.8) (#26132) server: preserve websocket close code when proxying to outposts (#26090) * server: preserve websocket close code when proxying to outposts The websocket proxy that bridges outpost connections to the gunicorn/uvicorn backend replaced every relayed close frame with a code-less close (`Message::Close(None)`), discarding the status code and reason from the peer. When a web worker is recycled (routinely, via web.max_requests) or restarted on upgrade, uvicorn closes the outpost websocket gracefully with 1012 (service restart). Because the proxy relayed `Close(None)`, the outpost instead received a close frame with no status code, which surfaces as `websocket: close 1005 (no status)` and is logged at warning level - indistinguishable from a genuine fault, so a healthy deployment warns on every recycle and trips outpost-disconnect alerting. The reverse direction stripped the outpost's own close code too. Relay the received close frame verbatim in both directions so the peer sees the real close code and reason. The tail-of-stream case (peer closes without sending a Close frame) still sends `Close(None)`, which is correct. * no claude comments --------- Signed-off-by: Jens Langhammer <[email protected]> Co-authored-by: The Ginger <[email protected]> Co-authored-by: Claude Opus 4.8 <[email protected]> Co-authored-by: Jens Langhammer <[email protected]>
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Details
What does this PR change?
The server's websocket reverse proxy (
src/server/core.rs,handle_websocket_connection) relays every close frame asMessage::Close(None), dropping the original status code and reason. This forwards the received close frame unchanged instead, in both directions.Why is this change needed?
When a web worker is recycled (
web.max_requests) or the server restarts, uvicorn closes the outpost websocket gracefully with code 1012 (service restart). The proxy relayed a code-less close, so the outpost sawwebsocket: close 1005 (no status)and logged it at warning level — indistinguishable from a real fault. On a busy instance every recycle produces one, tripping false "outpost disconnected" alerts even though the outpost reconnects normally. The reverse direction dropped the outpost's own close code too.How was this tested?
cargo test --bin authentik server::core::websockets— existing proxy tests pass.web.max_requests=100, sent ~800 requests to force worker recycles, and confirmed the outposts loggedwebsocket: close 1012on each recycle. The same recycles producedclose 1005 (no status)before the patch.Linked issues
None — happy to open one if preferred.
AI assistance: root-cause analysis and the patch were done with AI (Claude), reviewed and tested by me. I understand the change and take responsibility for it.
I'm also happy to send a follow-up PR making the outpost log expected close codes (1012/1001) at debug rather than warning, which clears the remaining alert noise.
Checklist
cargo test --bin authentik server::core::websockets); fullmake allnot run locally — CI covers it.