Skip to content

Commit 4f34452

Browse files
authored
fix: use separate http.Transports for wsproxy tests (coder#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 coder/internal#112
1 parent 93e8239 commit 4f34452

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

‎enterprise/coderd/coderdenttest/proxytest.go‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,12 @@ func NewWorkspaceProxyReplica(t *testing.T, coderdAPI *coderd.API, owner *coders
146146

147147
logger := testutil.Logger(t).With(slog.F("server_url", serverURL.String()))
148148

149+
// nolint: forcetypeassert // This is a stdlib transport it's unnecessary to type assert especially in tests.
149150
wssrv, err := wsproxy.New(ctx, &wsproxy.Options{
150-
Logger: logger,
151+
Logger: logger,
152+
// It's important to ensure each test has its own isolated transport to avoid interfering with other tests
153+
// especially in shutdown.
154+
HTTPClient: &http.Client{Transport: http.DefaultTransport.(*http.Transport).Clone()},
151155
Experiments: options.Experiments,
152156
DashboardURL: coderdAPI.AccessURL,
153157
AccessURL: accessURL,

‎enterprise/wsproxy/wsproxysdk/wsproxysdk.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,7 @@ func (l *RegisterWorkspaceProxyLoop) failureFn(err error) {
453453
if deregisterErr != nil {
454454
l.opts.Logger.Error(context.Background(),
455455
"failed to deregister workspace proxy with Coder primary (it will be automatically deregistered shortly)",
456+
slog.F("root_error", err.Error()),
456457
slog.Error(deregisterErr),
457458
)
458459
}

0 commit comments

Comments
 (0)