Add note about capturing h

This commit is contained in:
Francis Lavoie 2026-04-21 08:17:49 -04:00
parent 4ef0e8a9a5
commit b0dc5d8bb8
No known key found for this signature in database

View File

@ -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 {