Skip to content

Commit 27f3b7a

Browse files
authored
fix: add timeout to listening ports request (#11935)
This can potentially hang for 15m if the agent is unreachable.
1 parent 7f1c808 commit 27f3b7a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

coderd/workspaceagents.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,11 @@ func (api *API) workspaceAgentListeningPorts(rw http.ResponseWriter, r *http.Req
722722
ctx := r.Context()
723723
workspaceAgent := httpmw.WorkspaceAgentParam(r)
724724

725+
// If the agent is unreachable, the request will hang. Assume that if we
726+
// don't get a response after 30s that the agent is unreachable.
727+
ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
728+
defer cancel()
729+
725730
apiAgent, err := db2sdk.WorkspaceAgent(
726731
api.DERPMap(), *api.TailnetCoordinator.Load(), workspaceAgent, nil, nil, nil, api.AgentInactiveDisconnectTimeout,
727732
api.DeploymentValues.AgentFallbackTroubleshootingURL.String(),

0 commit comments

Comments
 (0)