anomalyco / anomalyco/opencode

perf: bound instance SSE subscriber queues

Open
#45,215 2 comments 0 reactions 1 assignee View on GitHub

@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
  1. Open an instance SSE subscription.
  2. Stop or severely throttle reads from the response.
  3. Generate sustained message.part.updated events with large part payloads.
  4. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.