Skip to content

Commit 19023e7

Browse files
committed
fix(codersdk): Use AwaitReachable in DialWorkspaceAgent
1 parent 1a90599 commit 19023e7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

codersdk/workspaceagents.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,13 +199,19 @@ func (c *Client) DialWorkspaceAgent(ctx context.Context, agentID uuid.UUID, opti
199199
return nil, err
200200
}
201201

202-
return &WorkspaceAgentConn{
202+
agentConn := &WorkspaceAgentConn{
203203
Conn: conn,
204204
CloseFunc: func() {
205205
cancelFunc()
206206
<-closed
207207
},
208-
}, nil
208+
}
209+
if !agentConn.AwaitReachable(ctx) {
210+
_ = agentConn.Close()
211+
return nil, xerrors.Errorf("timed out waiting for agent to become reachable: %w", ctx.Err())
212+
}
213+
214+
return agentConn, nil
209215
}
210216

211217
// WorkspaceAgent returns an agent by ID.

0 commit comments

Comments
 (0)