Skip to content

fix(websocket): Preserve stable client IP and expand websocket CI Go matrix#1802

Closed
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-weird-websocket-string
Closed

fix(websocket): Preserve stable client IP and expand websocket CI Go matrix#1802
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-weird-websocket-string

Conversation

Copilot AI commented Apr 11, 2026

Copy link
Copy Markdown
Contributor
  • Review new PR feedback and locate affected websocket test
  • Run baseline websocket tests before changes
  • Inspect CI workflow runs context for websocket checks
  • Refactor websocket regression test to avoid fixed port and busy-spin readiness loop
  • Run targeted websocket tests after changes
  • Run final validation (Code Review + CodeQL)
  • Commit/push and reply to PR comment with commit hash

Copilot AI linked an issue Apr 11, 2026 that may be closed by this pull request
3 tasks
Copilot AI changed the title [WIP] Fix weird websocket string from IP() websocket: preserve stable client IP by copying request IP string Apr 11, 2026
Copilot AI requested a review from gaby April 11, 2026 19:54
Copilot finished work on behalf of gaby April 11, 2026 19:54
@gaby gaby changed the title websocket: preserve stable client IP by copying request IP string fix(websocket): Preserve stable client IP Apr 11, 2026
@ReneWerner87 ReneWerner87 added the ☢️ Bug Something isn't working label Apr 11, 2026
@gaby

gaby commented Apr 11, 2026

Copy link
Copy Markdown
Member

@copilot add go 1.26.x to test workflow for websocket.

@gaby gaby marked this pull request as ready for review April 11, 2026 20:02
@gaby gaby requested a review from a team as a code owner April 11, 2026 20:02
@gaby gaby requested review from ReneWerner87, Copilot, efectn and sixcolors and removed request for a team April 11, 2026 20:02

Copilot AI commented Apr 11, 2026

Copy link
Copy Markdown
Contributor Author

@copilot add go 1.26.x to test workflow for websocket.

Done in 1465f4c — added Go 1.26.x to the websocket test workflow matrix.

Copilot AI changed the title fix(websocket): Preserve stable client IP fix(websocket): Preserve stable client IP and expand websocket CI Go matrix Apr 11, 2026
Copilot finished work on behalf of gaby April 11, 2026 20:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a data corruption issue in v3/websocket where Conn.IP() could become unstable due to retaining a request-scoped string on a pooled connection object, and adds a regression test to ensure the IP remains stable while other websocket requests are processed.

Changes:

  • Copy the request IP with utils.CopyString when initializing websocket connection state to avoid fasthttp buffer reuse corruption.
  • Add a regression test that holds one websocket connection open while repeatedly creating additional websocket connections with different proxied IP headers.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
v3/websocket/websocket.go Copies the IP string before storing it on the pooled websocket Conn, preventing request-buffer reuse corruption.
v3/websocket/websocket_test.go Adds a regression test intended to validate Conn.IP() stability across subsequent websocket requests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +377 to +392
go app.Listen(":3000", fiber.ListenConfig{DisableStartupMessage: true})
defer app.Shutdown()

readyCh := make(chan struct{})
go func() {
for {
conn, err := net.Dial("tcp", "localhost:3000")
if err != nil {
continue
}
conn.Close()
readyCh <- struct{}{}
return
}
}()
<-readyCh

Copilot AI Apr 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test starts a real server on a hard-coded ":3000" and waits for readiness via an infinite busy-spin dial loop. If the port is already in use or app.Listen fails, the test can hang indefinitely and burn CPU. Consider using an ephemeral/in-memory listener (see v3/socketio/socketio_test.go using fasthttputil.NewInmemoryListener() + app.Listener) or, at minimum, capture/handle the Listen error and add a bounded timeout + small backoff in the readiness loop.

Copilot uses AI. Check for mistakes.
@gaby

gaby commented Apr 11, 2026

Copy link
Copy Markdown
Member

@copilot apply changes based on the comments in this thread

@ReneWerner87

Copy link
Copy Markdown
Member

replaced by #1803

Copilot stopped work on behalf of gaby due to an error April 11, 2026 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

☢️ Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants