Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 88d49db

Browse files
authored
fix: Add isFirst check before err check (#4326)
This was causing TestBlockNonBrowser to hang and fail.
1 parent c7aea2f commit 88d49db

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

codersdk/workspaceagents.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -331,21 +331,21 @@ func (c *Client) DialWorkspaceAgentTailnet(ctx context.Context, logger slog.Logg
331331
// Need to disable compression to avoid a data-race.
332332
CompressionMode: websocket.CompressionDisabled,
333333
})
334-
if err != nil {
335-
if errors.Is(err, context.Canceled) {
336-
return
337-
}
338-
logger.Debug(ctx, "failed to dial", slog.Error(err))
339-
continue
340-
}
341334
if isFirst {
342-
if res.StatusCode == http.StatusConflict {
335+
if err != nil && res.StatusCode == http.StatusConflict {
343336
first <- readBodyAsError(res)
344337
return
345338
}
346339
isFirst = false
347340
close(first)
348341
}
342+
if err != nil {
343+
if errors.Is(err, context.Canceled) {
344+
return
345+
}
346+
logger.Debug(ctx, "failed to dial", slog.Error(err))
347+
continue
348+
}
349349
sendNode, errChan := tailnet.ServeCoordinator(websocket.NetConn(ctx, ws, websocket.MessageBinary), func(node []*tailnet.Node) error {
350350
return conn.UpdateNodes(node)
351351
})

0 commit comments

Comments
 (0)