fix(api): subscribe to gsoc before websocket upgrade - #5639
Merged
Merged
Conversation
Upgrade flushes the 101 response, so the client can trigger a GSOC update before the handler subscribed, silently dropping it. Register the subscription before upgrading and release it if the upgrade fails. Fixes flaky TestGsocWebsocketSingleHandler and TestGsocWebsocketSocFields timeouts in the master coverage job. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sbackend123
approved these changes
Oct 3, 2026
gacevicljubisa
approved these changes
Oct 3, 2026
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.
Checklist
Description
The master
Coverage Reportjob has been failing intermittently since #5614 withTestGsocWebsocketSingleHandler/TestGsocWebsocketSocFieldshitting a 30si/o timeout(e.g. run 36754977013).gsocWsHandlercalledupgrader.Upgradebefores.gsoc.Subscribe.Upgradeflushes the 101 response, so the client'sDialcan return and a GSOC update can be delivered before the subscription is registered — the update is then silently dropped. Coverage instrumentation slows the handler enough to widen this window, which is why only the master-only coverage job was red. Real clients are affected the same way (a first update can be lost).This change registers the subscription (and the shared wrapped-chunk cache subscription) before upgrading, and releases them if the upgrade fails. Updates arriving before the writer goroutine starts are buffered in the queue and picked up via
wake.Verification: injecting a 50ms sleep between
UpgradeandSubscribeon master reproduces the exact CI failure; with this change, the same sleep afterUpgradeno longer causes failures.go test -cover ./pkg/api/andgo test -race -run Gsoc -count=5 ./pkg/api/pass.Open API Spec Version Changes (if applicable)
N/A
AI Disclosure
🤖 Generated with Claude Code