Skip to content

Keep chat subscribers alive after a rejected changeApplied callback - #314

Open
hidcc wants to merge 2 commits into
cloudflare:mainfrom
hidcc:fix-chat-subscriber-drop-305
Open

Keep chat subscribers alive after a rejected changeApplied callback#314
hidcc wants to merge 2 commits into
cloudflare:mainfrom
hidcc:fix-chat-subscriber-drop-305

Conversation

@hidcc

@hidcc hidcc commented Aug 24, 2026

Copy link
Copy Markdown

Fixes #305.

What does this change?

Since #275, a rejected changeApplied callback removes the subscriber from #chatSubscribers (and the subscribeToChat replay path calls unsubscribe on 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 changeApplied rejection handlers (the live broadcast in emitChatChangeApplied and the retained-row replay in subscribeToChat) log the rejection and keep the subscription, matching the mitigation described in #305. Dead clients are still removed through the existing subscriber.onRpcBroken(() => unsubscribe()) handler.

Why is this obviously correct and trivially verifiable?

The patch only changes what happens after a changeApplied promise 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 .catch changes, and disconnect cleanup is unchanged (onRpcBrokenunsubscribe, visible a few lines above the replay site).

Verified locally: a regression test (a subscriber whose changeApplied rejects once must still receive the next row) fails on main and passes with this patch — kept out of this PR to stay within the line limit, available at hidcc:regression-test-305. The full chat-changes.test.ts suite passes, and vp lint / tsc -p packages/workshop-backend are clean.

Checklist

Checking every item does not guarantee acceptance. Maintainers determine whether
a pull request meets the contribution policy.

  • This is a small, concrete change; it is not a feature, refactor, or low-value cleanup.
  • I understand that maintainers decide whether the change is obviously correct and trivially verifiable.
  • I have read and followed the contribution guidelines.

🤖 Generated with Claude Code

hidcc and others added 2 commits August 24, 2026 17:11
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>
The test lives on the regression-test-305 branch, referenced from the PR.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions github-actions Bot added the kernel Changes to the Workshop kernel label Aug 24, 2026
@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@hidcc

hidcc commented Aug 24, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@hidcc

hidcc commented Aug 24, 2026

Copy link
Copy Markdown
Author

recheck

github-actions Bot added a commit that referenced this pull request Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kernel Changes to the Workshop kernel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chat subscription can silently stop during an agent turn until the page is refreshed

1 participant