From e9b0bc7d747dd735c9998bd38065dc87657f5cc4 Mon Sep 17 00:00:00 2001 From: Daniel Liu <139250065@qq.com> Date: Mon, 28 Apr 2025 09:12:42 +0800 Subject: [PATCH] node: ensure resp.body closed #26969 (#987) --- node/rpcstack_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/node/rpcstack_test.go b/node/rpcstack_test.go index 03ec42c48e..f50c80d921 100644 --- a/node/rpcstack_test.go +++ b/node/rpcstack_test.go @@ -290,6 +290,7 @@ func baseRpcRequest(t *testing.T, url, bodyStr string, extraHeaders ...string) * if err != nil { t.Fatal(err) } + t.Cleanup(func() { resp.Body.Close() }) return resp } @@ -506,7 +507,6 @@ func TestHTTPWriteTimeout(t *testing.T) { // Send normal request t.Run("message", func(t *testing.T) { resp := rpcRequest(t, url, "test_sleep") - defer resp.Body.Close() body, err := io.ReadAll(resp.Body) if err != nil { t.Fatal(err) @@ -520,7 +520,6 @@ func TestHTTPWriteTimeout(t *testing.T) { t.Run("batch", func(t *testing.T) { want := fmt.Sprintf("[%s,%s,%s]", greetRes, timeoutRes, timeoutRes) resp := batchRpcRequest(t, url, []string{"test_greet", "test_sleep", "test_greet"}) - defer resp.Body.Close() body, err := io.ReadAll(resp.Body) if err != nil { t.Fatal(err)