You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SSE event streams leak memory on client disconnect #15645
SSE event streams in server.ts and routes/global.ts leak memory when clients disconnect. The stream.writeSSE() calls are fire-and-forget, so write failures to dead connections go undetected. Bus listeners and heartbeat intervals keep accumulating across reconnects.
In long-running sessions with many reconnects, this causes steady memory growth (~15+ MB observed) from orphaned listeners and intervals that are never cleaned up.
Steps to reproduce
Start the OpenCode server (bun dev serve)
Open multiple SSE connections (e.g. via browser tabs or curl)
Close the connections abruptly (kill the client without a clean close)
Repeat steps 2-3 many times
Observe that Bus subscription counts grow and memory usage increases steadily
Activity
github-actions commentedon Mar 2, 2026
This issue might be a duplicate of existing issues. Please check:
serveandwebcommands leak child processes on exit; SSE heartbeat interval leaks on server-initiated close #14091: Specifically covers SSE heartbeat interval leaks when the server closes a stream viastream.close()(Hono'sonAbortnot firing), andBus.subscribeAllsubscriptions accumulating — which is the same root cause described hereBus.subscribesubscriptions leaking across the codebaseIf your issue is already covered by one of those, please consider adding details there instead.
abrekhov commentedon Mar 20, 2026
+1 — confirmed this is the root cause of the 60GB+ OOM crashes reported in #17908. Added detailed diagnostics and root-cause trace there.
thdxr commentedon Apr 2, 2026
Closing in favor of #20695 where we're collecting all memory-related problems. Please follow that issue for updates.