Skip to content

Drop cached propvals before a replacing Loro import - #1707

Closed
michielbdejong wants to merge 1 commit into
developfrom
fix/replace-snapshot-drops-removed
Closed

michielbdejong wants to merge 1 commit into
developfrom
fix/replace-snapshot-drops-removed

Conversation

@michielbdejong

Copy link
Copy Markdown
Contributor

Refs #1703. Ported from #1705 so develop gets the fix without waiting for the plugin-debug stack.

Bug

Resource.importLoroUpdate(bytes, replace = true) in browser/lib/src/resource.ts rebuilds the LoroDoc but kept the cached propvals map. The heal pass in getLoroDoc() then wrote every cached key that the new snapshot lacked back into the doc as a local change. So a property removed on the source came back on this client, and the client never sent that change back.

Every full-state replace hits this, not only /app-write.

Fix

Before the rebuild, clear the cache, keeping only server-derived keys (isDerivedByServer), which never live in Loro. This is the same 8 lines as in #1705.

Test

a replacing snapshot drops properties the source removed in browser/lib/src/resource.test.ts. It fails without the fix (expected 'Goes away' to be undefined) and passes with it.

cd browser/lib && NODE_OPTIONS=--no-experimental-webstorage pnpm test: 959 passed, 1 skipped.

🤖 Generated with Claude Code

`importLoroUpdate(bytes, replace = true)` rebuilt the LoroDoc but kept the
cached propvals. `getLoroDoc()`'s heal pass then wrote every cached key the
new snapshot lacked back into the doc as a local change, so a property
removed at the source reappeared on this client. Clear the cache first,
keeping only server-derived keys, which never live in Loro.

Ported from #1705. Refs #1703.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@michielbdejong michielbdejong added bug Something isn't working @tomic/lib @tomic/lib labels Sep 24, 2026
joepio added a commit that referenced this pull request Sep 25, 2026
…rdown (#1644, #1707, #1708) (#1853)

Combined batch, green on Mancave on e0c9c47 (CI and Downstream).

Includes #1644, #1707 and #1708, plus the blank lines lib lint asks for
in #1707's change.

joepio commented Sep 25, 2026

Copy link
Copy Markdown
Member

Landed on develop in f0721f0 via the combined batch #1853 (green on Mancave). Closing.


Generated by Claude Code

@joepio joepio closed this Sep 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working @tomic/lib @tomic/lib

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants