When xray.run() subscribes to GET /v1/replays/:id/events while the replay is still analyzing, the stream can terminate without a complete chunked body once the terminal event is reached. The client raises httpx.RemoteProtocolError: peer closed connection without sending complete message body (incomplete chunked read), which propagates straight out of run().
Observed reproducibly on replays whose evaluation holds the stream open across multiple events (e.g. a conversation with a judge). Replays that complete near-instantly (no judges/assertions) hit the late-subscriber path instead and close cleanly.
The replay itself completes server-side — GET /v1/replays/:id/result returns the full verdict — so the SDK crash discards a result that exists.
The live-listener path in src/server/replays/replays.router.ts (~L416-485) issues void stream.writeSSE(...) per event (unawaited, unserialized; ReplayEvents.emit is synchronous) and returns from the callback on terminal without draining pending writes. _wait_for_evaluation in sdk/python/src/xray/orchestrator.py (~L358) has no transport-error handling and no /result fallback.
When
xray.run()subscribes toGET /v1/replays/:id/eventswhile the replay is stillanalyzing, the stream can terminate without a complete chunked body once the terminal event is reached. The client raiseshttpx.RemoteProtocolError: peer closed connection without sending complete message body (incomplete chunked read), which propagates straight out ofrun().Observed reproducibly on replays whose evaluation holds the stream open across multiple events (e.g. a conversation with a judge). Replays that complete near-instantly (no judges/assertions) hit the late-subscriber path instead and close cleanly.
The replay itself completes server-side —
GET /v1/replays/:id/resultreturns the full verdict — so the SDK crash discards a result that exists.The live-listener path in
src/server/replays/replays.router.ts(~L416-485) issuesvoid stream.writeSSE(...)per event (unawaited, unserialized;ReplayEvents.emitis synchronous) and returns from the callback on terminal without draining pending writes._wait_for_evaluationinsdk/python/src/xray/orchestrator.py(~L358) has no transport-error handling and no/resultfallback.