Repository navigation
Description
Summary
A single active session can wedge the shared opencode serve instance and make unrelated webapp routes hang.
This is happening in production right now on http://100.68.120.26:4096.
Current impact
- Session page hangs/blank-loads for unrelated sessions.
curl --max-time 8 http://100.68.120.26:4096/global/healthtimes out with0 bytes.curl --max-time 8 http://100.68.120.26:4096/L1VzZXJzL2VuZ2luZWVyL3dvcmtzcGFjZS92aWJlYnJvd3Nlci92aWJl/session/ses_30526a392ffegNvJj3VONZughBtimes out with0 bytes.
Evidence
- Port
4096listener is the root.opencode serve --hostname 100.68.120.26process. - The root process ballooned to multi-GB RSS / footprint and stopped responding before sending headers.
watchdog.ndjsonshows the new root process (20427parent /20428child) jumping from ~3.3 GBtree RSS to ~5.36 GBquickly, with repeated spikes afterward.sampleon the child showed ~6.5 GBphysical footprint and ~8.7 GBpeak during the wedge.- DB size is small (
opencode.db~11 MB,62sessions,839messages,2910parts), so this is not a giant-history issue. - Serve logs show the process healthy until it enters an extreme
message.part.deltapublish storm around2026-03-17 08:40 UTC-07, after which unrelated web routes stop making progress.
Likely trigger
The likely triggering session is:
- session id:
ses_3050c2b49ffejDdZpPUK5zEPsU - title:
6 months review and update of CV - directory:
/Users/engineer/workspace/vibebrowser/vibe
Root cause hypothesis
This looks like an event-stream amplification problem, not a specific bad session page.
Relevant paths:
packages/opencode/src/session/processor.ts- emits one
message.part.deltabus event per model chunk fortext-deltaandreasoning-delta
- emits one
packages/opencode/src/bus/index.ts- logs every bus publish at info level, including every
message.part.delta
- logs every bus publish at info level, including every
packages/opencode/src/server/routes/global.ts- subscribes to
GlobalBusand callsawait stream.writeSSE(...)inside an async event-emitter listener
- subscribes to
packages/opencode/src/server/server.ts- same async-per-event SSE pattern for
/event
- same async-per-event SSE pattern for
packages/opencode/src/acp/agent.ts- secondary amplification risk: refetches the full message on every
message.part.delta
- secondary amplification risk: refetches the full message on every
The most direct webapp failure mode is that the server-side SSE relays queue unbounded async writes during a delta storm. Since EventEmitter.emit() does not await async listeners, a hot session can accumulate huge numbers of pending writeSSE() promises and JSON payloads, driving memory/CPU up until the shared serve instance stops responding.
Expected fix shape
- Add a bounded/coalescing server-side relay for
/global/eventand/event. - Merge repeated
message.part.deltachunks per part while a write is in flight. - Drop stale delta events when a newer
message.part.updatedsupersedes them in the queue. - Stop logging every
message.part.deltaat info level. - Optionally cache part type in ACP so it does not fetch the full message on every delta.
Repro notes
The failure is live as of 2026-03-17.
Useful local artifacts:
~/.local/share/opencode/log/2026-03-17T081027.log~/.local/share/opencode/log/watchdog.ndjson~/.local/share/opencode/log/memory/2026-03-17T16-24-11-664Z
Activity
github-actions commentedon Mar 17, 2026
This issue doesn't fully meet our contributing guidelines.
What needs to be fixed:
Please edit this issue to address the above within 2 hours, or it will be automatically closed.
This issue might be a duplicate of existing issues. Please check:
opencode webbecomes unresponsive after hours — SSE connection leak causes memory growth and event loop freeze (same symptoms: HTTP server stops responding including /global/health, same root cause of async SSE writes and dead connections)opencode serveconsuming unbounded RAM until OOM killIf you believe this was flagged incorrectly, please let a maintainer know.
dzianisv commentedon Mar 17, 2026
Investigation is complete and a fix is up in PR #17979.
What changed:
/event,/global/event, and the workspace control-plane event streammessage.part.deltachunks while a write is in flightmessage.part.updatedsupersedes themmessage.part.deltabus publish logging from info to debugValidation run:
bun test test/server/relay.test.ts test/acp/event-subscription.test.ts --timeout 30000frompackages/opencodebun typecheckfrompackages/opencodebun turbo typecheckvia the push hookdzianisv commentedon Mar 17, 2026
Tactical recovery update: I manually restarted
opencode serveon March 17, 2026 after confirming the old instance was wedged. As of the restart check, both/global/healthand the previously hanging session URL are returning200again. This restores the webapp temporarily while PR #17979 carries the permanent fix.dzianisv commentedon Mar 17, 2026
Final deployment/update note:
origin/devas802a6fd3abcf1d8df01494923fd853a5c4b82479origin/devbranch withbun run install:localopencode serveon March 17, 2026 and brought it back onhttp://100.68.120.26:4096GET /global/health=>{"healthy":true,"version":"0.0.0-local-202603171756"}GitHub side:
anomaly/devbase so the patch is represented cleanly there as wellDIRTYstate is resolved; current PR state isBLOCKEDby normal GitHub merge policy, not by merge conflictsgithub-actions commentedon Mar 17, 2026
This issue has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.
Feel free to open a new issue that follows our issue templates.