Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(codersdk): Use AwaitReachable in DialWorkspaceAgent
  • Loading branch information
mafredri committed Feb 21, 2023
commit 19023e75b3263f5f2da7e5220efa45d1c4a727c0
10 changes: 8 additions & 2 deletions codersdk/workspaceagents.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,19 @@ func (c *Client) DialWorkspaceAgent(ctx context.Context, agentID uuid.UUID, opti
return nil, err
}

return &WorkspaceAgentConn{
agentConn := &WorkspaceAgentConn{
Conn: conn,
CloseFunc: func() {
cancelFunc()
<-closed
},
}, nil
}
if !agentConn.AwaitReachable(ctx) {
_ = agentConn.Close()
return nil, xerrors.Errorf("timed out waiting for agent to become reachable: %w", ctx.Err())
}

return agentConn, nil
}

// WorkspaceAgent returns an agent by ID.
Expand Down