Replace gorilla/websocket with coder/websocket#1633
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
There was a problem hiding this comment.
Pull request overview
This PR migrates the project’s WebSocket usage in the e2e test harness from github.com/gorilla/websocket to github.com/coder/websocket, aiming to improve context-aware operations and close handling while addressing concerns about the gorilla/websocket dependency.
Changes:
- Switched WebSocket dial/read/write in e2e helpers/tests to
github.com/coder/websocket. - Introduced context-based dialing and updated close handling to send a normal close status.
- Updated module dependencies to add
github.com/coder/websocketand adjust WebSocket-related requirements.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
test/helpers/traffic.go |
Updates WebSocket dialing helper to use coder/websocket and adds timeout context + close status. |
test/e2e/default/websocket_test.go |
Updates the e2e WebSocket echo test to use coder/websocket Read/Write APIs. |
go.mod |
Adds coder/websocket and keeps gorilla/websocket listed as indirect. |
go.sum |
Adds checksums for coder/websocket. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
99c1ec9 to
0b37059
Compare
Fedosin
left a comment
There was a problem hiding this comment.
Nit (low priority): In coder/websocket, the response body from Dial is already consumed by the library — you never need to close resp.Body yourself. This line is harmless but misleading, as it implies the caller has responsibility for the body. Consider removing it to avoid confusion for future readers.
(test/helpers/traffic.go, line 157: _ = resp.Body.Close())
0b37059 to
c4a39c3
Compare
linkvt
left a comment
There was a problem hiding this comment.
Woups, seems that the tests dont work anymore, please make sure that published code was also tested as this just causes more work for us now going back and forth.
8ce79e6 to
ca0db32
Compare
linkvt
left a comment
There was a problem hiding this comment.
Thanks for updating the PR, tests still seem to be failing.
You can run the tests locally as documented here: https://github.com/kedacore/http-add-on/blob/main/docs/developing.md#running-e2e-tests
Let me know in case the docs don't work for you!
|
The e2e test failure is caused by a difference in how Root cause: In contrast, Fix: put the virtual hostname in the URL and use a custom func (f *Framework) WebSocketDial(host, path string) *websocket.Conn {
f.t.Helper()
ctx, cancel := context.WithTimeout(f.ctx, 45*time.Second)
defer cancel()
wsURL := url.URL{Scheme: "ws", Host: host, Path: path}
conn, _, err := websocket.Dial(ctx, wsURL.String(), &websocket.DialOptions{
HTTPClient: &http.Client{
Transport: &http.Transport{
DialContext: func(ctx context.Context, network, _ string) (net.Conn, error) {
return (&net.Dialer{Timeout: 10 * time.Second}).DialContext(ctx, network, f.proxyAddr)
},
},
},
})
if err != nil {
f.t.Fatalf("WebSocket dial to %s%s failed: %v", host, path, err)
}
f.t.Cleanup(func() { _ = conn.Close(websocket.StatusNormalClosure, "") })
return conn
}This way the |
|
Thanks Fedosin and Vincent for your inputs. am pushing new changes. |
2e36e99 to
9a63696
Compare
- Updated go.mod to use github.com/coder/websocket v1.8.12 - Migrated test/helpers/traffic.go to use coder/websocket API - Updated test/e2e/default/websocket_test.go to use new API - Added context support for WebSocket operations - Improved close handling with proper status codes Fixes kedacore#1617 Signed-off-by: S. Akram Jaaveed <akramjaaveed.aj@gmail.com>
9a63696 to
c28da96
Compare
Fixes #1617