fix(shared-state): avoid echoing received updates - #422
Draft
dvcolomban wants to merge 1 commit into
Draft
dvcolomban wants to merge 1 commit into
dvcolomban wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
This was referenced Oct 2, 2026
This branch was previously deployed
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.
Background
A browser-side shared-state update received from the node side emits the same write back. If that write arrives after its key is deleted and recreated, the replacement accepts the old synchronization ID and loses its new value.
Changes
Suppress only the received state object and synchronization ID while applying a snapshot or patch. Restore the previous receive context after synchronous callbacks. Local writes, nested callback writes and writes to another key with the same ID still propagate.
The production change adds 20 lines and removes 3 in one file. No public API or wire-format change.
Reproduction
The added tests use native
RpcFunctionsHostImplandcreateRpcSharedStateClientHost. Only outgoing I/O is queued.{ count: 5 }from the node side and deliver its update to the browser side. Hold the resulting outgoing write.{ count: 6 }. Read the replacement normally.In a disposable checkout of this branch, install the locked dependencies with
pnpm install --frozen-lockfile. Run the same tests with the production file restored to the unchanged base, then with the fix:Verification
72d917d5, using native source only.devframeTypeScript checks and thedevframepackage build pass.Local source checks use a cached dependency graph with Vitest 5.0.1, TypeScript 6.0.3 and Vite 8.3.1. Full CI also passes with the current lockfile: lint, Ubuntu/Windows Node 22/24/26 test jobs, end-to-end tests and Bun/Deno runtime checks.