Skip to content

Commit 969eeaa

Browse files
committed
fix: add timeout to listening ports request
This can potentially hang for 15m if the agent is unreachable.
1 parent 73a6899 commit 969eeaa

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

coderd/workspaceagents.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,8 @@ func (api *API) workspaceAgentLogs(rw http.ResponseWriter, r *http.Request) {
761761
func (api *API) workspaceAgentListeningPorts(rw http.ResponseWriter, r *http.Request) {
762762
ctx := r.Context()
763763
workspaceAgent := httpmw.WorkspaceAgentParam(r)
764+
ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
765+
defer cancel()
764766

765767
apiAgent, err := db2sdk.WorkspaceAgent(
766768
api.DERPMap(), *api.TailnetCoordinator.Load(), workspaceAgent, nil, nil, nil, api.AgentInactiveDisconnectTimeout,

0 commit comments

Comments
 (0)