fix: allow cross-origin WebSocket and fix Redis stream MINID format - #23
Merged
Conversation
Two issues preventing browser extension WebSocket connections: 1. websocket.Accept rejected connections from chrome-extension:// origins because the coder/websocket library's default origin check requires Origin to match Host. Browser extensions send their extension ID as Origin. Fix: set OriginPatterns: ["*"] since auth is via token in query params. Also re-apply the Cloudflare HTTP/1.0 workaround that was lost in a recent merge. 2. Redis XADD failed with "Invalid stream ID" because the approximate trimming prefix "~" was concatenated into the MinID string instead of using the go-redis Approx field. Fix: use Approx: true with a plain MinID value.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThe PR modifies Redis stream trimming logic in the stream publisher and updates WebSocket upgrade handling to detect HTTP/1.0 requests and force HTTP/1.1, while also changing origin validation options during the WebSocket accept step. Changes
🚥 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 |
rcoderdev
marked this pull request as draft
April 5, 2026 04:58
rcoderdev
marked this pull request as ready for review
April 5, 2026 09:23
Merged
3 tasks
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.
Summary
Two bugs preventing browser extension WebSocket connections to the notification server:
WebSocket Origin rejection —
websocket.Accept(w, r, nil)uses thecoder/websocketlibrary's default origin check, which requires theOriginheader to match theHostheader. Browser extensions sendOrigin: chrome-extension://<id>, causing 403 rejection. Fix: setOriginPatterns: ["*"]— authentication is already handled via the token in query params. Also re-applies the Cloudflare HTTP/1.0 workaround that was lost in a recent merge.Redis Streams MINID format —
XAddwas called withMinID: "~" + minID, concatenating the approximate-trimming prefix into the ID string itself. go-redis v9 expectsApprox: trueas a separate field. The~-prefixed string is an invalid stream ID, causingERR Invalid stream ID specified as stream command argument.Testing
POST /notify→ notification delivered via Redis Streams → WebSocket → extension showed the keysign notification bannerSummary by CodeRabbit