mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: Add isFirst check before err check (#4326)
This was causing TestBlockNonBrowser to hang and fail.
This commit is contained in:
@@ -331,6 +331,14 @@ func (c *Client) DialWorkspaceAgentTailnet(ctx context.Context, logger slog.Logg
|
||||
// Need to disable compression to avoid a data-race.
|
||||
CompressionMode: websocket.CompressionDisabled,
|
||||
})
|
||||
if isFirst {
|
||||
if err != nil && res.StatusCode == http.StatusConflict {
|
||||
first <- readBodyAsError(res)
|
||||
return
|
||||
}
|
||||
isFirst = false
|
||||
close(first)
|
||||
}
|
||||
if err != nil {
|
||||
if errors.Is(err, context.Canceled) {
|
||||
return
|
||||
@@ -338,14 +346,6 @@ func (c *Client) DialWorkspaceAgentTailnet(ctx context.Context, logger slog.Logg
|
||||
logger.Debug(ctx, "failed to dial", slog.Error(err))
|
||||
continue
|
||||
}
|
||||
if isFirst {
|
||||
if res.StatusCode == http.StatusConflict {
|
||||
first <- readBodyAsError(res)
|
||||
return
|
||||
}
|
||||
isFirst = false
|
||||
close(first)
|
||||
}
|
||||
sendNode, errChan := tailnet.ServeCoordinator(websocket.NetConn(ctx, ws, websocket.MessageBinary), func(node []*tailnet.Node) error {
|
||||
return conn.UpdateNodes(node)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user