ReviewOS

also looking at this

stacks/stx

fix(hmr): send SSE keepalive every 5s so /_stx/hmr survives idle timeouts

#1778
Merged glennmichael123 wants to merge fix/hmr-keepalive-sse into main
3 files +345 -43
9 days ago

Problem

The HMR live-reload EventSource (/_stx/hmr) sent its keepalive comment every 15s, but that is longer than Bun.serve's 10s default idleTimeout (and typical reverse-proxy read timeouts, e.g. rpx). The stream went idle and the connection was killed before the first keepalive ever arrived, so the browser reported net::ERR_INCOMPLETE_CHUNKED_ENCODING and EventSource fell into a reconnect loop — very visible behind the *.localhost HTTPS proxy as repeated failed GET /_stx/hmr.

The original code comment even claimed 15s was "well under any sane idle timeout (Bun's default 10s)" — but 15 > 10.

Fix

Drop the keepalive interval to 5s, comfortably under Bun's 10s default and common proxy read timeouts.

Verified

Streaming /_stx/hmr now emits a keepalive at +5s and +10s (was +15s); the connection stays alive and the reconnect loop is gone.

🤖 Generated with Claude Code

3 changed files on the files tab, with 0 review threads.

Sign in to comment on this pull request.