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

Skip to content

Commit 00d0620

Browse files
authored
fix: Fix err check in DialWorkspaceAgentTailnet (#4320)
1 parent 78a39a8 commit 00d0620

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

codersdk/workspaceagents.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -331,22 +331,18 @@ 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 errors.Is(err, context.Canceled) {
335-
return
336-
}
337-
if isFirst {
338-
if res.StatusCode == http.StatusConflict {
339-
first <- readBodyAsError(res)
334+
if err != nil {
335+
if errors.Is(err, context.Canceled) {
340336
return
341337
}
342-
isFirst = false
343-
close(first)
344-
}
345-
if err != nil {
346338
logger.Debug(ctx, "failed to dial", slog.Error(err))
347339
continue
348340
}
349341
if isFirst {
342+
if res.StatusCode == http.StatusConflict {
343+
first <- readBodyAsError(res)
344+
return
345+
}
350346
isFirst = false
351347
close(first)
352348
}

0 commit comments

Comments
 (0)