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
The SSE event stream at /event?directory=... can silently drop without sending TCP FIN, causing HTTP clients using ReadableStream (like Node.js fetch().body.getReader()) to hang forever on reader.read() — no error, no {done: true}.
This occurs mid-prompt: OpenCode continues processing internally (tokens generated visible in session API), but events stop flowing to connected SSE clients.
When any error occurs in eventData (JSON.stringify failure on BigInt, circular refs, etc.), Effect-TS interruption mechanism cancels the stream. Bun then cancels the ReadableStream WITHOUT calling controller.close() or sending the final zero-length chunk (0\r\n\r\n) for chunked transfer encoding. The TCP connection stays open with no data flowing. Node.js reader.read() interprets this as idle and blocks forever.
Fix Suggestions
Wrap JSON.stringify in try/catch in eventData() — catch serialization errors and emit an error event instead of crashing the pipeline
Change haltStrategy from "left" to "either" — so heartbeat continues even if event stream errors
Always send [DONE] or proper TCP close on stream termination, error or clean
Reproduction
Run OpenCode with a model that produces large nested tool call results (subagent tasks). After some time (1-5 minutes into a prompt), the SSE stream stops. OpenCode session API shows continued token generation. Client hangs indefinitely.
Activity
github-actions commentedon May 21, 2026
This issue might be a duplicate of existing issues. Please check:
github-actions commentedon Jul 21, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.