A real-time analytics platform makes Claude API calls and needs to display streaming responses in a React frontend. The team implements an event stream consumer that processes SSE events. During testing, they observe that when network interruptions occur mid-stream, the EventSource auto-reconnects but the reconnection URL doesn't include the conversation state, causing Claude to start a fresh generation. Users see the response restart from the beginning. What is the correct implementation pattern?
Select an answer to reveal the explanation.
Short Explanation and Infographic
Here's the deal — the SSE specification includes built-in support for resumable streams via Last-Event-ID. The server assigns incrementing IDs to each event chunk, the browser automatically tracks and sends the last received ID in the Last-Event-ID header on reconnection, and the server can resume from a buffer rather than regenerating.
Full explanation below image
Full Explanation
The SSE specification includes built-in support for resumable streams via Last-Event-ID. The server assigns incrementing IDs to each event chunk, the browser automatically tracks and sends the last received ID in the Last-Event-ID header on reconnection, and the server can resume from a buffer rather than regenerating. This requires server-side buffering of the active stream's chunks, but not the full pre-completion buffering of Option C. Option A (replay full request) is the described current behavior — Claude regenerates, which is expensive and inconsistent (the regenerated response differs from the interrupted one). Option C (full pre-stream buffering) trades the reconnection problem for eliminated streaming UX — users wait for complete generation before seeing anything. Option D (30-second reconnect intervals) reduces reconnection frequency but doesn't fix what happens when a reconnection does occur.