From b0dc5d8bb87581a651b2cabb0d7176b908d6027f Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Tue, 21 Apr 2026 08:17:49 -0400 Subject: [PATCH] Add note about capturing h --- modules/caddyhttp/reverseproxy/streaming.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/caddyhttp/reverseproxy/streaming.go b/modules/caddyhttp/reverseproxy/streaming.go index c93a57e47..3f6b40cd9 100644 --- a/modules/caddyhttp/reverseproxy/streaming.go +++ b/modules/caddyhttp/reverseproxy/streaming.go @@ -193,7 +193,8 @@ func (h *Handler) handleUpgradeResponse(logger *zap.Logger, rw http.ResponseWrit // gracefully close connections we recognize as websockets. We need to make // sure the client connection messages (i.e. to upstream) are masked, so we // need to know whether the connection is considered the server or the - // client side of the proxy. + // client side of the proxy. Note that gracefulClose must not capture h, + // since the tunnel may outlive the handler instance. gracefulClose := func(conn io.ReadWriteCloser, isClient bool) func() error { if isWebsocket(req) { return func() error {