Skip to content

Fix SSE relay backlog during delta storms - #17979

Closed
dzianisv wants to merge 1 commit into
anomalyco:devfrom
dzianisv:fix/17977-event-relay
Closed

dzianisv wants to merge 1 commit into
anomalyco:devfrom
dzianisv:fix/17977-event-relay

Conversation

@dzianisv

Copy link
Copy Markdown

Summary

  • add a coalescing server-side relay for SSE event streams so one hot session cannot queue unbounded async writeSSE() work
  • use the relay for /event, /global/event, and the workspace control-plane event stream
  • lower message.part.delta bus publish logging from info to debug and add relay regression tests

Root cause

message.part.delta storms were being forwarded one-by-one through async EventEmitter listeners that called await stream.writeSSE(...). Since EventEmitter does not await async listeners, slow consumers could accumulate an unbounded backlog of pending writes and payload allocations, eventually wedging the shared serve instance.

Testing

  • bun test test/server/relay.test.ts test/acp/event-subscription.test.ts --timeout 30000 (from packages/opencode)
  • bun typecheck (from packages/opencode)
  • bun turbo typecheck (ran via push hook)

Closes #17977.

@github-actions

Copy link
Copy Markdown
Contributor

Hey! Your PR title Fix SSE relay backlog during delta storms doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Mar 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@dzianisv
dzianisv force-pushed the fix/17977-event-relay branch from e301a18 to b0e96ee Compare March 17, 2026 17:52
@dzianisv

Copy link
Copy Markdown
Author

Deployment/update note:

  • rebased the PR branch cleanly onto anomaly/dev and force-updated fix/17977-event-relay so the PR is no longer DIRTY
  • cherry-picked the same patch onto origin/dev and pushed it there as commit 802a6fd3abcf1d8df01494923fd853a5c4b82479
  • ran on the clean origin/dev worktree:
    • bun test test/server/relay.test.ts test/acp/event-subscription.test.ts --timeout 30000
    • bun typecheck
  • ran the same two checks on the clean anomaly/dev PR worktree
  • built and installed the local binary from origin/dev with bun run install:local
  • restarted opencode serve on 100.68.120.26:4096 using the newly installed binary
  • verified live endpoints after restart:
    • /global/health => {"healthy":true,"version":"0.0.0-local-202603171756"}
    • the previously hanging session URL now returns the OpenCode HTML document again

The earlier push hook failure was environmental (No space left on device in .turbo cache inside the temp worktree), not a code failure; the manual checks above completed successfully on both rebased branches.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Webapp serve can wedge under message.part.delta storm from one session

1 participant