Repository navigation
fix(streaming): prevent bursty Responses SSE delivery - #123
Merged
lidge-jun merged 2 commits intoJul 14, 2026
Merged
Conversation
Yield between same-turn bridge events so Bun can flush SSE frames before a synchronous upstream burst is coalesced into one downstream delivery. Add a real HTTP regression test for issue #114.
Owner
|
Reviewed; the approach looks sound. Macrotask-boundary yielding in bridgeToResponsesSSE splits synchronous adapter bursts without reordering, benefits all routed providers, and leaves native Responses passthrough unaffected. Before this leaves draft, we would like:
|
Contributor
Author
|
Addressed the measurable/regression-test requests in commit
The requested real macOS Codex Desktop app-server retest remains environment-blocked here because this runner is Windows and has no macOS app-server binary. The PR remains draft pending that owner-side macOS validation against the production Codex Desktop path described in #114. |
lidge-jun
marked this pull request as ready for review
July 14, 2026 07:34
agentHits
pushed a commit
to agentHits/opencodex
that referenced
this pull request
Sep 17, 2026
…coalescing-pr fix(streaming): prevent bursty Responses SSE delivery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Issue #114 remained partially unresolved after #115. The upstream
Accept-Encoding: identitychange addressed compressed provider responses, but the Codex Desktop app-server could still receive the final answer as one burst when the bridge processed many adapter events in a single JavaScript turn.The observable symptom was:
item/agentMessage/deltanotifications within roughly 30 ms;Root cause
bridgeToResponsesSSEconsumes an async adapter event burst inside theReadableStream.start()task. When the upstream response body supplied many parsed text deltas without an event-loop gap, the bridge calledcontroller.enqueue()repeatedly in the same turn. Bun then exposed the queued frames to the downstream client as one large delivery.This explains why the previous compression fix could pass a simple curl reproduction while the full Codex request shape still appeared buffered.
Fix
Regression coverage
tests/bridge-live-delivery.test.tsstarts a real Bun HTTP server, feeds the bridge 40 synchronoustext_deltaevents, reads the response throughfetch(), and asserts that deltas arrive across multiple reads rather than one end burst.Verification
bun x tsc --noEmit: passed.git diff --check: passed.tests/claude-agents-inject.test.ts:92(EPERM) without symlink privileges.Risk and rollout
The change only affects bursty streaming delivery and keeps event ordering, terminal handling, cancellation, and heartbeat behavior unchanged. It may increase the number of downstream flush opportunities for providers that deliver many deltas in one response-body read, which is the intended behavior for interactive streaming.
Please retest with the real macOS Codex Desktop app-server path from issue #114.