Preserve server-first bytes buffered with an upgrade handshake
perfloop-oss/skipper · Uncatalogued correctness
https://perfloop.ai/t/oss/case_bbsc737fya
Verdict
VERIFIED · settled 2026-11-15 · pull request opened as zalando/skipper#4435
What happened: The check fails before this change and passes with it.
Hypothesis
A valid server-first WebSocket frame disappears when the backend sends it with the upgrade handshake. The client receives a valid 101 response but no frame. This is reproduced through Proxy.ServeHTTP with ExperimentalUpgrade enabled, with audit logging both off and on. Production frequency is unknown.
In upgradeProxy.serveHTTP, http.ReadResponse receives a newly created buffered reader at line 130. After a successful 101, both backend-to-client branches read backendConn directly at lines 185–189. Bytes already read beyond the HTTP headers remain in the abandoned reader. Writing resp does not recover those bytes. This claim concerns successful upgrades with response read-ahead, not every invocation or error response.
The new, provisional native check proxy/hunt_upgrade_serverfirst_test.go ran from the repository root with `go test ./proxy -run '^TestHuntUpgradeServerFirst(SingleRecord|AfterHandshake)$' -count=1 -timeout=30s -v`. Each failing subtest is a deterministic witness: one valid handshake and the three-byte text frame 810178 in one TLS record. Both audit=false and audit=true failed with `server-first frame lost: want 810178, got (0 bytes)` and an `i/o timeout`. TestHuntUpgradeServerFirstAfterHandshake passed in both modes when the same frame followed in a separate TLS record after the client read the 101. Each frame-read bound was one second. The client sent no application data. The scratch test file was removed after the run.
The Case proof target is exact, ordered byte preservation from the backend across the HTTP-to-upgraded-stream boundary, including audit output and ordinary subsequent bidirectional traffic. The smallest useful next check is to make this witness and its split-record control pass, then cover payload and buffer boundaries. The test layout is provisional, not an additional fixed delivery requirement. A whole upgrade-engine replacement is not needed to establish this property; preservation of the client hijack reader has not been shown to fail under valid WebSocket timing.
Current upstream inspection found no open PR changing proxy/upgrade.go. The actual patches in https://github.com/zalando/skipper/pull/4430, https://github.com/zalando/skipper/pull/4425 and https://github.com/zalando/skipper/pull/4341 respectively change ordinary response-copy logging, hedging after the experimental-upgrade branch, and other backend transports. They do not preserve the abandoned response reader. Prior-repair searches for websocket, upgradeProxy and the concrete buffer mechanism found no matching repair. History remains a gap: the checkout is shallow and the code-host commits endpoint refused the bounded read. The proposal Drive archive also refused access; the public group lookup returned a page but did not establish archive coverage. AGENTS.md requires a human-authored issue and PR description for this kind of contribution; no maintainer acceptance or publication authority is assumed.
Change to test: Preserve the response parser's buffered input when forwarding every successful upgrade, including the audited path, so bytes read with the handshake reach the client exactly once and in order. Keep non-101 responses, bidirectional connection ownership and connection cleanup compatible.
Where it lives
perfloop-oss/skipper · proxy/proxy.go
Evidence
The check fails before this change and passes with it: `With ExperimentalUpgrade enabled, successful WebSocket upgrades preserve server-first frames and subsequent bidirectional frames exactly once and in order, including audit output when enabled, for frames sent with or after the handshake and around the response-buffer boundary.`
Checks: 5 of 5 passed. Verification: no defect found.
Timeline
2026-11-15· Case opened2026-11-15· PR opened