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.updated events 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
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-volumemessage.part.updatedpayloads.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/opencodeOpenCode version
Current v2 development source
Steps to reproduce
message.part.updatedevents with large part payloads.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