Commit 13ce811f by Marcus Efraimsson Committed by GitHub

Chore: Remove warning when calling resource (#30752)

Fixes so that the warning WARN Failed to close 
stream logger=plugins.backend err="cannot 
close a closed stream" is not logged every 
time calling a resource.
parent 3b7b49a4
......@@ -262,13 +262,17 @@ func (m *manager) callResourceInternal(w http.ResponseWriter, req *http.Request,
childCtx, cancel := context.WithCancel(req.Context())
defer cancel()
stream := newCallResourceResponseStream(childCtx)
var wg sync.WaitGroup
wg.Add(1)
defer func() {
if err := stream.Close(); err != nil {
m.logger.Warn("Failed to close stream", "err", err)
}
wg.Wait()
}()
var wg sync.WaitGroup
wg.Add(1)
var flushStreamErr error
go func() {
flushStreamErr = flushStream(p, stream, w)
......@@ -278,11 +282,6 @@ func (m *manager) callResourceInternal(w http.ResponseWriter, req *http.Request,
if err := p.CallResource(req.Context(), crReq, stream); err != nil {
return err
}
if err := stream.Close(); err != nil {
return err
}
wg.Wait()
return flushStreamErr
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment