Skip to content

Deliver SSE terminal frames after a mailbox overflow - #338

Merged
tylerreckart merged 4 commits into
mainfrom
fix/sse-mailbox-force-deliver-after-overflow
Sep 21, 2026
Merged

tylerreckart merged 4 commits into
mainfrom
fix/sse-mailbox-force-deliver-after-overflow

Conversation

@cursor

@cursor cursor Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Problem

sse_mailbox_push returns false as soon as overflowed is set. force_deliver is supposed to evict oldest events so a terminal SSE envelope (env.terminal on request replay and A2A resubscribe) still lands and the stream can close cleanly.

The overflow check ran first. A full mailbox that rejected one more live event therefore also dropped the subsequent done / task-status frame. The subscriber drain loop in handle_request_events / A2A resubscribe then wrote slow_consumer and exited without the real terminal. The existing unit test only covered force-deliver while the mailbox was full but not yet overflowed.

Fix

Honor force_deliver after overflow: evict oldest items if still at cap, push the terminal envelope, and clear overflowed so the drain loop writes that frame instead of aborting.

Non-terminal pushes after overflow still reject.

Tests

unit_sse_mailbox — overflow then force-deliver: terminal is at the back, overflowed is cleared, dropped live event never queued. All 3 cases / 6163 assertions locally (including ASan). Consumer-loop probe matching the API drain also delivered done instead of slow_consumer.

Independently mergeable against main (0456350). Code hunks (include/sse_mailbox.h, tests/test_sse_mailbox.cpp) do not overlap #321–#337. git merge-tree --write-tree auto-merges those siblings, including CHANGELOG [Unreleased].

Open in Web View Automation 

Note

Low Risk
Small, targeted change to bounded SSE buffering with a new regression test; affects slow-client stream teardown only, not normal event delivery.

Overview
Fixes a bug where slow SSE subscribers could miss the real stream ending after the mailbox had already overflowed.

sse_mailbox_push no longer rejects every push once overflowed is set. With force_deliver=true (terminal done / task-status envelopes), it still evicts oldest buffered events if needed, enqueues the terminal frame, and clears overflowed so the drain loop emits that frame instead of only slow_consumer. Non-terminal pushes after overflow still fail as before.

Adds a unit test for overflow-then-force-deliver and documents the fix in CHANGELOG.

Reviewed by Cursor Bugbot for commit 46172fa. Bugbot is set up for automated code reviews on this repo. Configure here.

sse_mailbox_push returned false for force_deliver once overflowed was
set, so a full mailbox that rejected one more live event also dropped
the subsequent terminal envelope. Request replay and A2A resubscribe
then closed as slow_consumer without the real done/status. Honor
force_deliver after overflow and clear the flag so the drain loop
can write the terminal frame.

Co-authored-by: Tyler Reckart <tylerreckart@users.noreply.github.com>
Keep both Unreleased changelog entries.

Co-authored-by: Cursor <cursoragent@cursor.com>
@cursor

cursor Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_fe8d9707-329b-43bb-8e35-a32e167dbd70)

Keep both Unreleased changelog entries.

Co-authored-by: Cursor <cursoragent@cursor.com>
Keep both Unreleased changelog entries.

Co-authored-by: Cursor <cursoragent@cursor.com>
@tylerreckart
tylerreckart merged commit 56f7462 into main Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants