Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addressed a data race condition in the server tests #23

Merged
merged 2 commits into from
Sep 27, 2024

Conversation

kpumuk
Copy link
Contributor

@kpumuk kpumuk commented Sep 24, 2024

Addresses a data race in the server tests.

To reproduce:

go test ./... -race

Output before the change:

==================
WARNING: DATA RACE
Read at 0x00c000536398 by goroutine 589:
  github.com/basecamp/kamal-proxy/internal/server.TestTarget_DrainRequestsThatCompleteWithinTimeout.func1()
      /Users/dmytro/work/github/kamal-proxy/internal/server/target_test.go:246 +0x40
  net/http.HandlerFunc.ServeHTTP()
      /Users/dmytro/go/pkg/mod/golang.org/[email protected]/src/net/http/server.go:2220 +0x48
  net/http.serverHandler.ServeHTTP()
      /Users/dmytro/go/pkg/mod/golang.org/[email protected]/src/net/http/server.go:3210 +0x2a8
  net/http.(*conn).serve()
      /Users/dmytro/go/pkg/mod/golang.org/[email protected]/src/net/http/server.go:2092 +0xe58
  net/http.(*Server).Serve.gowrap3()
      /Users/dmytro/go/pkg/mod/golang.org/[email protected]/src/net/http/server.go:3360 +0x4c

Previous write at 0x00c000536398 by goroutine 590:
  github.com/basecamp/kamal-proxy/internal/server.TestTarget_DrainRequestsThatCompleteWithinTimeout.func1()
      /Users/dmytro/work/github/kamal-proxy/internal/server/target_test.go:246 +0x50
  net/http.HandlerFunc.ServeHTTP()
      /Users/dmytro/go/pkg/mod/golang.org/[email protected]/src/net/http/server.go:2220 +0x48
  net/http.serverHandler.ServeHTTP()
      /Users/dmytro/go/pkg/mod/golang.org/[email protected]/src/net/http/server.go:3210 +0x2a8
  net/http.(*conn).serve()
      /Users/dmytro/go/pkg/mod/golang.org/[email protected]/src/net/http/server.go:2092 +0xe58
  net/http.(*Server).Serve.gowrap3()
      /Users/dmytro/go/pkg/mod/golang.org/[email protected]/src/net/http/server.go:3360 +0x4c

@kevinmcconnell
Copy link
Collaborator

Thanks for the fix, @kpumuk!

@kevinmcconnell kevinmcconnell merged commit 397b839 into basecamp:main Sep 27, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants