Skip to content

Commit 5017052

Browse files
committed
fix non-blocking channel send to prevent deadlock in webhook listener mode
1 parent 28d43da commit 5017052

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

service/runtime/handler.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,14 @@ func (h *Handler) ServeHTTP(rw http.ResponseWriter, inReq *http.Request) {
194194
if path == tokenEndpoint && requestBody != nil {
195195
uc := h.parseAuthTokenBody(requestBody)
196196
if !uc.Empty() && h.userCredentialsCh != nil {
197-
h.userCredentialsCh <- uc
197+
// Non-blocking: the channel has no reader when tnls.Start()
198+
// exits early (e.g. TunnelIsReady fails), which would deadlock
199+
// this goroutine and hang the already-completed HTTP response.
200+
select {
201+
case h.userCredentialsCh <- uc:
202+
default:
203+
ll.Log("webhook listener not ready, skipping credentials forwarding")
204+
}
198205
}
199206
}
200207
}

0 commit comments

Comments
 (0)