GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||
GeezerVison is showing github.com — fix(sse): prevent memory leak from zombie SSE connections by zhumengzhu · Pull Request #22550 · anomalyco/opencode ConversationProblemEvery SSE endpoint ( const stop = () => { clearInterval(heartbeat) // 10s heartbeat timer unsub() // Bus.subscribeAll subscription q.push(null) // unblock the for-await loop } stream.onAbort(stop) // ← only cleanup path In TCP CLOSE_WAIT — the Electron shell reconnecting on minimize/restore, or a The With 66–74 zombie connections observed in the wild, RSS grew at ~14 MB/sec Full root cause analysis with sequence and flow diagrams: FixFour changes across four files:
stream.onAbort(stop) c.req.raw.signal.addEventListener("abort", stop) // added
If neither abort path fires, the next write to a dead socket throws. Cleanup try { await stream.writeSSE({ data }) } catch { stop() return }
Added an optional
Each SSE connection registers one listener on The existing TestingFull test suite: 1890 pass, 1 fail — the failing test Targeted tests for the changed logic:
Raw output: Note: a direct before/after RSS comparison on Linux local connections is not Prior artApproach for
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsSSE connections stuck in TCP CLOSE_WAIT never triggered stream.onAbort(), leaving AsyncQueue, heartbeat intervals, and Bus subscriptions running forever — causing unbounded memory growth (~14 MB/sec, peak 24.5 GB). Four changes across four files: - util/queue.ts: add capacity limit (default 1000), drop oldest entry on overflow — defensive backstop so growth is bounded even if cleanup is missed - server/instance/event.ts: listen on c.req.raw.signal as a second abort path; wrap writeSSE in try/catch and call stop() on write failure - server/instance/global.ts: same two changes applied to streamEvents() which backs /global/event and /global/sync-event - bus/global.ts: raise GlobalBus.setMaxListeners to 100 — each SSE connection adds one listener; the default limit of 10 causes MaxListenersExceededWarning under normal concurrent usage Fixes anomalyco#22198, fixes anomalyco#22422 Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Contributor
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Contributor
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ReviewersNo reviewsUh oh!
There was an error while loading. Please reload this page. AssigneesNo one assignedLabels
needs:compliance
ProjectsMilestoneNo milestoneDevelopmentSuccessfully merging this pull request may close these issues. Memory Leak Warning Memory leak: SSE connections stuck in CLOSE_WAIT cause unbounded AsyncQueue growth (~14 MB/sec)Uh oh!
There was an error while loading. Please reload this page. 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. | ||
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |