Skip to content

fix(server): bound SSE event queues#31094

Open
ShamirSecret wants to merge 2 commits into
anomalyco:devfrom
ShamirSecret:codex/fix-sse-event-queues
Open

fix(server): bound SSE event queues#31094
ShamirSecret wants to merge 2 commits into
anomalyco:devfrom
ShamirSecret:codex/fix-sse-event-queues

Conversation

@ShamirSecret

Copy link
Copy Markdown

Issue for this PR

Closes #31087
Closes #22198

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Long-running or stale SSE clients can make the server retain event buffers indefinitely. The instance /event stream currently uses an unbounded queue, and events are queued before they are filtered by instance/workspace. The global event stream has the same backpressure risk through its callback stream.

This PR bounds those SSE event buffers:

  • instance /event uses a sliding queue with a fixed capacity
  • instance events are filtered by instance/workspace before entering the queue
  • global events use a sliding queue with a fixed capacity

When a client is slow or stale, older progress events may be dropped in favor of newer ones. This keeps memory bounded without changing task execution, model context, tool results, or final session state.

This addresses the unbounded event-buffer growth described in #22198. It does not attempt to fully redesign SSE replay semantics or connection liveness detection.

How did you verify your code works?

From packages/opencode:

bun typecheck

Screenshots / recordings

N/a

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant