From afb4c62fbf6839319dbe93c1bbb9eb7fc9a67c3e Mon Sep 17 00:00:00 2001 From: Devon Rifkin Date: Fri, 6 Mar 2026 19:18:52 -0800 Subject: [PATCH] cloud_proxy: handle stream disconnects gracefully (#14685) Previously we were printing out bad errors for expected cases like clients disconnecting. Now we only debug log when that happens (which still might help in cases where we're figuring out why an integration isn't working). For other errors, we print out a proper warning now --- server/cloud_proxy.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/server/cloud_proxy.go b/server/cloud_proxy.go index bf91d7694..f08b6a456 100644 --- a/server/cloud_proxy.go +++ b/server/cloud_proxy.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "encoding/json" + "errors" "fmt" "io" "log/slog" @@ -204,7 +205,25 @@ func proxyCloudRequestWithPath(c *gin.Context, body []byte, path string, disable c.Status(resp.StatusCode) if err := copyProxyResponseBody(c.Writer, resp.Body); err != nil { - c.Error(err) //nolint:errcheck + ctxErr := c.Request.Context().Err() + if errors.Is(err, context.Canceled) && errors.Is(ctxErr, context.Canceled) { + slog.Debug( + "cloud proxy response stream closed by client", + "path", c.Request.URL.Path, + "status", resp.StatusCode, + ) + return + } + + slog.Warn( + "cloud proxy response copy failed", + "path", c.Request.URL.Path, + "status", resp.StatusCode, + "request_context_canceled", ctxErr != nil, + "request_context_err", ctxErr, + "error", err, + ) + return } }