Repository navigation
fix(dashboard): SSE backpressure + liveness — stop unbounded write buffering that OOM-crashed the dashboard after ~39h - #664
Merged
Conversation
…ffering that OOM-crashed the dashboard after ~39h A stalled SSE client (background-throttled tab, sleeping laptop, half-open TCP) never fires 'close', and res.write() never throws — it buffers. Every 2 s broadcast (~60 KB for a penster batch) accumulated in that buffer until V8's 4 GB heap limit: 140,714,810 ms uptime / 2000 ms ≈ 70k ticks ≈ 60 KB per tick, matching the crash exactly. - writeToSseClients(): skip a client with writableNeedDrain or a write buffer over 2 MB; drop (destroy + remove) after 15 consecutive stalled ticks (~30 s); log drops. Extracted as a pure function for tests. - handleSSE(): ': ping' comment every 15 s and a 90 s socket idle timeout so a dead peer surfaces as error/close; remove the client on close/error from both req and res; clear the ping timer on removal. Test: dashboard-sse-backpressure.test.ts (7) incl. the 39-hour scenario — a permanently stalled client is dropped holding < ~2.1 MB. 4142 pass.
HenryLach
added a commit
that referenced
this pull request
Sep 18, 2026
fix(dashboard): SSE stall eviction is elapsed-time based; one idempotent teardown for every exit path (Sage review of #664)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A stalled SSE client (background-throttled tab, sleeping laptop, half-open
TCP) never fires 'close', and res.write() never throws — it buffers. Every
2 s broadcast (~60 KB for a penster batch) accumulated in that buffer until
V8's 4 GB heap limit: 140,714,810 ms uptime / 2000 ms ≈ 70k ticks ≈ 60 KB
per tick, matching the crash exactly.
buffer over 2 MB; drop (destroy + remove) after 15 consecutive stalled
ticks (~30 s); log drops. Extracted as a pure function for tests.
a dead peer surfaces as error/close; remove the client on close/error from
both req and res; clear the ping timer on removal.
Test: dashboard-sse-backpressure.test.ts (7) incl. the 39-hour scenario —
a permanently stalled client is dropped holding < ~2.1 MB. 4142 pass.