Keep chat subscribers alive after a rejected changeApplied callback - #313
Keep chat subscribers alive after a rejected changeApplied callback#313hidcc wants to merge 1 commit into
Conversation
A rejected changeApplied callback removed the subscriber from #chatSubscribers even though the RPC connection was still healthy, leaving the page connected but permanently unsubscribed: the chat UI silently stopped updating mid-turn until a refresh re-subscribed it. Log the rejection and keep the subscription instead, in both the live broadcast path and the subscribeToChat replay path. Dead clients are still removed by their onRpcBroken handler. Adds a regression test that fails on the previous behavior. Fixes cloudflare#305 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
|
Thank you for taking the time to contribute. This pull request was automatically closed because:
Please update the pull request to meet these automatic checks, then reopen it. Passing these checks does not guarantee acceptance; maintainers still determine whether a change is obviously correct and trivially verifiable. If an exception is appropriate, a maintainer can apply the |
Fixes #305.
What does this change?
Since #275, a rejected
changeAppliedcallback removes the subscriber from#chatSubscribers(and thesubscribeToChatreplay path callsunsubscribeon rejection), even though one rejected callback does not mean the RPC connection is broken. The page stays connected but permanently unsubscribed, so the chat UI silently stops updating during an agent turn until a refresh re-subscribes it.This patch makes both
changeAppliedrejection handlers (the live broadcast inemitChatChangeAppliedand the retained-row replay insubscribeToChat) log the rejection and keep the subscription, matching the mitigation described in #305. Dead clients are still removed through the existingsubscriber.onRpcBroken(() => unsubscribe())handler.Why is this obviously correct and trivially verifiable?
The patch only changes what happens after a
changeAppliedpromise rejects: previously the subscriber was dropped (silently, with the error swallowed); now the error is logged with the existing logger convention and the subscriber is kept. No control flow before the.catchchanges, and disconnect cleanup is unchanged (onRpcBroken→unsubscribe, visible a few lines above the replay site).Verified locally: a regression test (a subscriber whose
changeAppliedrejects once must still receive the next row) fails onmainand passes with this patch — kept out of this PR to stay within the line limit, available athidcc:regression-test-305. The fullchat-changes.test.tssuite passes, andvp lint/tsc -p packages/workshop-backendare clean.Checklist
Checking every item does not guarantee acceptance. Maintainers determine whether
a pull request meets the contribution policy.
🤖 Generated with Claude Code