From 99113bb5f620f1fd397dd35a971e8fc486522a15 Mon Sep 17 00:00:00 2001 From: Son Roy Almerol Date: Thu, 29 Aug 2024 17:59:30 -0400 Subject: [PATCH] check resp.Body if nil before attempting to close --- proxy/stream_handler.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/proxy/stream_handler.go b/proxy/stream_handler.go index 6727d52c..e2ebca0b 100644 --- a/proxy/stream_handler.go +++ b/proxy/stream_handler.go @@ -94,8 +94,10 @@ func (instance *StreamInstance) LoadBalancer(previous *[]int, method string) (*h utils.SafeLogf("[DEBUG] Error fetching stream from %s: %s\n", url, err.Error()) } - _, _ = io.Copy(io.Discard, resp.Body) - resp.Body.Close() + if resp.Body != nil { + _, _ = io.Copy(io.Discard, resp.Body) + resp.Body.Close() + } } if allSkipped {