fix(sse): heartbeat every 15s so the dashboard conn pill stops flapping #128

Merged
code-lead merged 1 commit from fix/sse-heartbeat into main 2026-04-20 11:18:20 +00:00
Collaborator

Symptom

Dashboard's connection pill flips connected → disconnected → connected every 20-30s even when the service is healthy.

Root cause

handleEvents opens the SSE stream and sends a single init message, then stays silent until a real event happens. Idle periods are common (no dispatches, no webhook traffic). After ~30s of no bytes, proxies / browsers / OSes drop the TCP connection; EventSource auto-reconnects, and the UI flaps.

Fix

Enqueue : heartbeat\n\n (an SSE comment line — ignored by the client) on every connected controller every 15s. Keeps intermediaries happy, no UI-visible traffic. Silently prunes dead controllers if enqueue throws.

16 lines in src/main.ts; no test needed — this is an observable behaviour, not a logic branch.

Verification

After merge + service restart: open /dashboard, leave it idle for 2 minutes — conn pill stays green throughout.

## Symptom Dashboard's connection pill flips `connected → disconnected → connected` every 20-30s even when the service is healthy. ## Root cause `handleEvents` opens the SSE stream and sends a single `init` message, then stays silent until a real event happens. Idle periods are common (no dispatches, no webhook traffic). After ~30s of no bytes, proxies / browsers / OSes drop the TCP connection; `EventSource` auto-reconnects, and the UI flaps. ## Fix Enqueue `: heartbeat\n\n` (an SSE comment line — ignored by the client) on every connected controller every 15s. Keeps intermediaries happy, no UI-visible traffic. Silently prunes dead controllers if `enqueue` throws. 16 lines in `src/main.ts`; no test needed — this is an observable behaviour, not a logic branch. ## Verification After merge + service restart: open `/dashboard`, leave it idle for 2 minutes — conn pill stays green throughout.
fix(sse): heartbeat every 15s so idle clients don't flap connected/disconnected
All checks were successful
qa / qa (pull_request) Successful in 2m59s
qa / dockerfile (pull_request) Successful in 12s
bd55d33e4f
An SSE connection with no messages triggers the 30s proxy/browser idle
drop, EventSource auto-reconnects, and the dashboard's connection pill
flips red→green every 20-30s. Keep intermediaries happy by enqueuing a
`: heartbeat\n\n` SSE comment line every 15s — ignored by the client but
counts as traffic.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
charles approved these changes 2026-04-20 11:16:15 +00:00
code-lead scheduled this pull request to auto merge when all checks succeed 2026-04-20 11:17:50 +00:00
code-lead deleted branch fix/sse-heartbeat 2026-04-20 11:18:20 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
charles/claude-hooks!128
No description provided.