Clawith icon indicating copy to clipboard operation
Clawith copied to clipboard

频繁出现RemoteProtocolError: peer closed connection without sending complete message body (incomplete chunked read)

Open liuzrong opened this issue 8 months ago • 1 comments

Pre-checks

Deployment Method

Docker

Steps to Reproduce

在执行任务的过程中频繁出现RemoteProtocolError: peer closed connection without sending complete message body (incomplete chunked read), 环境为本地vllm模型,128kb上下文,请求没有发送到vllm中,大家有没有遇到相同的问题。

Image

Expected vs Actual Behavior

任务执行成功

Logs / Screenshots

No response

liuzrong avatar Mar 30 '26 03:03 liuzrong

Thanks for the detailed report! We've identified and fixed this bug.

Root Cause

The LLM streaming client in llm_client.py had a narrow exception handler that only caught ConnectError, ReadError, and ConnectTimeout. However, httpx.RemoteProtocolError (raised when a server like vLLM closes the TCP connection mid-stream without sending a proper chunked response terminator) has a different inheritance path — it extends ProtocolError → TransportError, not NetworkError. So it bypassed the 3-attempt retry logic entirely and surfaced directly to the user.

This is especially common with local vLLM deployments under memory pressure or when context length is large (e.g. 128K), because vLLM may abruptly close the connection instead of returning a proper error response.

Fix

We've broadened the retry except clause from:

# Before — misses RemoteProtocolError
except (httpx.ConnectError, httpx.ReadError, httpx.ConnectTimeout) as e:

to:

# After — catches all transport-layer errors including RemoteProtocolError
except (httpx.TransportError, httpx.ConnectTimeout) as e:

httpx.TransportError is the base class for all transport-layer exceptions, covering both NetworkError subtypes (ConnectError, ReadError) and ProtocolError subtypes (RemoteProtocolError, LocalProtocolError). The existing 3-attempt retry with backoff (1s, 2s) will now apply to RemoteProtocolError as well.

This fix is included in the main branch as of commit 58aa5ad and will be part of the next release. To apply it now, pull the latest code and rebuild your backend container.

wisdomqin avatar Apr 02 '26 13:04 wisdomqin