diff --git a/proxy/proxy.go b/proxy/proxy.go index 55c45dc0..6c404109 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -288,6 +288,7 @@ func (p *Proxy) proxyStream( return err } connectSpan.End() + defer originConn.Close() encodedSpans := tr.GetSpans() @@ -295,15 +296,6 @@ func (p *Proxy) proxyStream( return err } - streamCtx, cancel := context.WithCancel(ctx) - defer cancel() - - go func() { - // streamCtx is done if req is cancelled or if Stream returns - <-streamCtx.Done() - originConn.Close() - }() - originConn.Stream(ctx, rwa, p.log) return nil }