fix(sessions): revert async prompt delivery β P0 regression (#3271)#3274
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
β Approved. P0 fast-track.
Surgical revert of the async fire-and-forget delivery pattern to synchronous await acpBackend.sendPrompt().
Root cause is clear: void deliverAsync() allowed the JSON-RPC session/prompt response to be lost in the event loop β CC processed the prompt but the tracking layer never received confirmation. The pending β polling pattern was broken by design.
Fix is correct:
- Reverts to synchronous
awaitβ proven pre-#3243 behavior - Keeps
promptDelivery.statusfield for backward compatibility (pending/delivered/failed/timeout) - Adds
errorfield to promptDelivery type β useful for debugging metrics.promptSent()called after delivery, not inside fire-and-forget
Tests: 8 tests rewritten from asyncβsynchronous assertions. All green. Covers: delivered, failed, thrown error (500), no-prompt session, status type variants.
CI: All green. fix: title β no bump gate issue.
All 9 merge gates pass. Merging immediately β P0 does not wait for rebase.
The async prompt delivery from #3243 caused a P0 regression: promptDelivery tracking hung indefinitely (status stuck at 'pending', attempts: 0) even though Claude Code received and processed the prompt. Root cause: the void deliverAsync() fire-and-forget pattern allowed the JSON-RPC session/prompt response to be lost β the tracking layer never received confirmation. The session/prompt request was sent, CC processed it, but the response never resolved the pending Promise (timeout after 120s β status: 'failed'). Fix: revert to synchronous await acpBackend.sendPrompt() which blocks until CC acknowledges receipt. This restores the proven pre-#3243 behavior. Changes: - src/routes/sessions.ts: revert async delivery to synchronous (keeps promptDelivery.status field for backward compat, adds error) - src/__tests__/async-session-create-3243.test.ts: rewrite tests for synchronous behavior (8 tests, all passing) Impact: promptDelivery.status will be 'delivered' or 'failed' immediately in the POST response, no longer 'pending'. The polling pattern is no longer needed. Closes #3271
cccbf7f to
13cfcfe
Compare
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.
Summary
Closes #3271 β P0 regression fix
Reverts the async prompt delivery from #3243 (#3253) to synchronous delivery. The async
void deliverAsync()pattern caused prompt delivery tracking to hang indefinitely.Root Cause
The fire-and-forget async delivery:
Three problems:
promptDelivery.statusstayspendingfor 120s until JSON-RPC timeout, thenfailedsession/promptrequest sends to CC, CC processes it, but the response never resolves the pending Promise (likely a transport/routing issue in the ACP JSON-RPC client)Fix
Revert to synchronous
await acpBackend.sendPrompt()β the proven pre-#3243 behavior. The POST blocks until CC acknowledges receipt.Verification
New/updated test:
async-session-create-3243.test.tsβ 8 tests covering:deliveredstatusfailedstatus with errorImpact
promptDelivery.statusis nowdeliveredorfailedimmediately in the POST responsependingβ polling pattern is no longer neededag runclients get immediate feedbackReproduction Evidence
Created 3 test sessions against running server (PID 107761, May 12 build):
promptDelivery: { delivered: false, attempts: 0, status: "pending" }for 60+ secondsstatus: "failed"after JSON-RPC timeout (120s)Post-merge
Server restart required to load the fix. The running instance (May 12 build) includes the broken async code.