From 28d5def2fb0541c2fcd337318c448f3639e38b59 Mon Sep 17 00:00:00 2001 From: ann-qin-lu Date: Fri, 23 Jan 2026 23:51:15 -0800 Subject: [PATCH] fix: use aread() to fully consume HTTP response body MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes CLOSE_WAIT connection issues with large response payloads (e.g. large router replay logits). The response.json() method may not fully read the response body, leaving bytes in the TCP receive buffer and causing connections to hang in CLOSE_WAIT state. Changes: - Use response.aread() + json.loads() instead of response.json() - Apply fix to both _post() and get() functions 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- slime/utils/http_utils.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/slime/utils/http_utils.py b/slime/utils/http_utils.py index 1e9082d52..12d7b9678 100644 --- a/slime/utils/http_utils.py +++ b/slime/utils/http_utils.py @@ -168,10 +168,11 @@ async def _post(client, url, payload, max_retries=60): try: response = await client.post(url, json=payload or {}) response.raise_for_status() + content = await response.aread() try: - output = response.json() + output = json.loads(content) except json.JSONDecodeError: - output = response.text + output = content.decode() if isinstance(content, bytes) else content except Exception as e: retry_count += 1 @@ -286,5 +287,6 @@ async def post(url, payload, max_retries=60): async def get(url): response = await _http_client.get(url) response.raise_for_status() - output = response.json() + content = await response.aread() + output = json.loads(content) return output