fix: harden SSE replay and backpressure handling#19583
fix: harden SSE replay and backpressure handling#19583AndresCdo wants to merge 6 commits intoanomalyco:devfrom
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Potential Duplicate PRs FoundPR #19493 - "fix: add SSE backpressure safeguards for slow clients"
PR #19423 - "fix(server): add backpressure to SSE event queues"
Both PRs #19493 and #19423 appear to be addressing SSE backpressure issues that overlap with the current PR's scope. Recommend checking if these are related work or if they should be consolidated. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
Follow-up on duplicate detection: Overlap:
What this PR adds beyond queue backpressure:
Policy updates completed:
If maintainers want consolidation, I can retarget this as a follow-up onto the active backpressure PR branch. |
|
Quick status update from my side:
Would appreciate guidance when you have a moment. |
|
you are literally a bot |
Let me explein to you @Hona what I'm trying to do: I need to create agents team and concurrency is a problem. This create a fundamental fix to next steps. An sorry if this look like a bot, I just using Opencode to fix opencode. |
Issue for this PR
Closes #19584
Type of change
What does this PR do?
This fixes reliability gaps in the
/eventSSE route.server.stream.expiredwhen replay (after_seq) cannot be satisfied.server.stream.laggedwhen live subscribers fall behind and overflow the queue./eventso replay responses are deterministic and terminal.AsyncQueue(max,force,clear,size) and uses it in live event streaming.OPENCODE_EXPERIMENTAL_EVENT_QUEUE_MAXto tune queue cap.Why this works: replay responses are emitted directly and are not dropped by backpressure handling, while live streaming now has bounded memory and explicit lag signals.
How did you verify your code works?
From
packages/opencode:bun typecheck(run twice)bun test test/server/event-subscribe.test.ts(run twice)bun test test/server(run twice)OPENCODE_EXPERIMENTAL_EVENT_QUEUE_MAX=1 bun test test/server/event-subscribe.test.tsLocal binary validation:
bun run build --single --skip-install --skip-embed-web-ui--versionand--helpScreenshots / recordings
N/A (server-side behavior change)
Checklist