anomalyco / anomalyco/opencode
perf: bound instance SSE subscriber queues
@neriousy is already working on this.
Since Aug 26, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
The instance event SSE handler creates an eager unbounded Queue.unbounded<EventV2.Payload>() for each subscriber and offers every full event payload into it. A slow or stalled subscriber can retain unlimited high-volume message.part.updated payloads.
Source: packages/opencode/src/server/routes/instance/httpapi/handlers/event.ts. Session.updatePart() publishes a full cloned part on every update.
Expected: each subscriber has a hard event/byte bound. Overflow disconnects explicitly or uses a safe sliding/coalescing policy. Cancellation always releases retained payloads, and terminal events are never silently lost.
This was found during a V8 OOM investigation. It is a confirmed unbounded source path, but it was not proven as that incident's heap owner because one saturated runtime sample had no live subscriber.
Plugins
@loreai/opencode
OpenCode version
Current v2 development source
Steps to reproduce
- Open an instance SSE subscription.
- Stop or severely throttle reads from the response.
- Generate sustained
message.part.updatedevents with large part payloads. - Observe that the subscriber queue grows without a configured event or byte limit until disconnect.
A regression should hold one subscriber stalled, publish sustained updates, assert bounded retained events/bytes, then cancel and assert full release.
Screenshot and/or share link
Not applicable; this is a server-side queue retention path.
Operating System
Linux
Terminal
OpenCode server mode
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.