fix: use separate http.Transports for wsproxy tests (#22292)

- Previously all tests were sharing the global http.Transport meaning on
`Close` it would close connections presumed to be idle for other tests.
fixes https://github.com/coder/internal/issues/112
This commit is contained in:
Jon Ayers
2026-02-24 23:56:58 -06:00
committed by GitHub
parent 93e823931b
commit 4f34452bcc
2 changed files with 6 additions and 1 deletions
+5 -1
View File
@@ -146,8 +146,12 @@ func NewWorkspaceProxyReplica(t *testing.T, coderdAPI *coderd.API, owner *coders
logger := testutil.Logger(t).With(slog.F("server_url", serverURL.String()))
// nolint: forcetypeassert // This is a stdlib transport it's unnecessary to type assert especially in tests.
wssrv, err := wsproxy.New(ctx, &wsproxy.Options{
Logger: logger,
Logger: logger,
// It's important to ensure each test has its own isolated transport to avoid interfering with other tests
// especially in shutdown.
HTTPClient: &http.Client{Transport: http.DefaultTransport.(*http.Transport).Clone()},
Experiments: options.Experiments,
DashboardURL: coderdAPI.AccessURL,
AccessURL: accessURL,
@@ -453,6 +453,7 @@ func (l *RegisterWorkspaceProxyLoop) failureFn(err error) {
if deregisterErr != nil {
l.opts.Logger.Error(context.Background(),
"failed to deregister workspace proxy with Coder primary (it will be automatically deregistered shortly)",
slog.F("root_error", err.Error()),
slog.Error(deregisterErr),
)
}