Skip to content

SSE stream drops mid-analysis, crashing xray.run() with RemoteProtocolError #78

Description

@LukasPoque

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions