Skip to content

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

Closed
hidcc wants to merge 1 commit into
cloudflare:mainfrom
hidcc:fix-chat-subscriber-drop-305
Closed

Keep chat subscribers alive after a rejected changeApplied callback#313
hidcc wants to merge 1 commit 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

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>
@github-actions github-actions Bot added the kernel Changes to the Workshop kernel label Aug 24, 2026
@github-actions

Copy link
Copy Markdown


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


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.

@github-actions

Copy link
Copy Markdown

Thank you for taking the time to contribute. This pull request was automatically closed because:

  • The "small, concrete change" confirmation is not checked.
  • The "maintainer assessment" confirmation is not checked.
  • The "contribution guidelines" confirmation is not checked.
  • The patch changes 49 lines; the automatic limit is 30.

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 policy/override label before reopening the pull request. See the contribution guidelines for details.

@github-actions github-actions Bot closed this 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

1 participant