SSE "net::ERR_INCOMPLETE_CHUNKED_ENCODING" in CI
Browsers report "net::ERR_INCOMPLETE_CHUNKED_ENCODING" when a chunked HTTP response (such as an SSE stream) is cut off before the final zero-length chunk. The stream ended abnormally, so the EventSource errors.
What this error means
A browser-based SSE test logs "net::ERR_INCOMPLETE_CHUNKED_ENCODING 200 (OK)" and the EventSource stops receiving events. It appears when the server or a proxy terminates the stream without a clean end.
GET http://localhost:8080/events net::ERR_INCOMPLETE_CHUNKED_ENCODING 200 (OK)Common causes
The server killed the stream without flushing an end
A worker that exits, or a handler that stops writing without properly ending the chunked response, leaves the chunked encoding incomplete.
A proxy buffered and truncated the stream
A reverse proxy that buffers responses can cut a long-lived SSE stream, producing an incomplete chunked encoding on the client.
How to fix it
End the stream cleanly and disable proxy buffering
- Flush data and end the response properly when the stream closes.
- Disable response buffering for the SSE route in any proxy.
- Send periodic keep-alive comments so the stream stays open.
location /events {
proxy_pass http://app;
proxy_buffering off;
proxy_read_timeout 3600s;
}Send keep-alive comments
Periodic comment lines keep the chunked stream alive and prevent idle truncation.
setInterval(() => res.write(':keep-alive\n\n'), 15000);How to prevent it
- Disable proxy buffering on SSE routes.
- Send periodic keep-alive comments on long-lived streams.
- End the chunked response cleanly when the stream closes.