@@ -716,10 +716,12 @@ local function request_chunk(self, method, path, opts, timeout)
716
716
" body: " , body , " query: " , query )
717
717
718
718
if not res then
719
+ http_cli :close ()
719
720
return nil , err
720
721
end
721
722
722
723
if res .status >= 300 then
724
+ http_cli :close ()
723
725
return nil , " failed to watch data, response code: " .. res .status
724
726
end
725
727
@@ -730,6 +732,7 @@ local function request_chunk(self, method, path, opts, timeout)
730
732
while (1 ) do
731
733
local chunk , read_err = res .body_reader ()
732
734
if read_err then
735
+ http_cli :close ()
733
736
return nil , read_err
734
737
end
735
738
if not chunk then
@@ -757,18 +760,21 @@ local function request_chunk(self, method, path, opts, timeout)
757
760
758
761
local chunks , split_err = split (body , [[ \n]] , " jo" )
759
762
if split_err then
763
+ http_cli :close ()
760
764
return nil , " failed to split chunks: " .. split_err
761
765
end
762
766
763
767
local all_events = {}
764
768
for _ , chunk in ipairs (chunks ) do
765
769
body , err = decode_json (chunk )
766
770
if not body then
771
+ http_cli :close ()
767
772
return nil , " failed to decode json body: " .. (err or " unknown" )
768
773
elseif body .error and body .error .http_code >= 500 then
769
774
-- health_check retry should do nothing here
770
775
-- and let connection closed to create a new one
771
776
health_check .report_failure (endpoint .http_host )
777
+ http_cli :close ()
772
778
return nil , endpoint .http_host .. " : " .. body .error .http_status
773
779
end
774
780
0 commit comments