Skip to content

BlockSet.exclude: compute the clock range before splitting structs - #826

Open
zurfyx wants to merge 1 commit into
yjs:mainfrom
zurfyx:fix/exclude-split-bounds
Open

zurfyx wants to merge 1 commit into
yjs:mainfrom
zurfyx:fix/exclude-split-bounds

Conversation

@zurfyx

@zurfyx zurfyx commented Oct 26, 2026

Copy link
Copy Markdown

Fixes #825.

Cause. BlockSet.exclude compared every range with the end of lastStruct, but findIndexCleanStart splits structs in place. When it split the last struct, that end moved back, so the following ranges were skipped instead of excluded. applyUpdate then integrated the block over structs the doc already had.

Fix. Compute the clock range of the blocks before the loop. I also changed return to continue for a client with nothing to exclude; readUpdateV2 can't reach that today.

Test. The repro from the issue (testApplyUpdateAroundGaps). It fails on main.

npm run lint stops at markdownlint on main (README.md line 143); standard and tsc pass.

findIndexCleanStart splits structs in place. When it split the last struct,
later ranges were compared against its new, shorter end and were not excluded.
applyUpdate then integrated a block over structs that the document already had.
The struct store overlapped itself, and the emitted update and
encodeStateAsUpdate could no longer be decoded.

Also continue with the next client instead of returning when a client has
nothing to exclude.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

applyUpdate can integrate a block over known structs around gaps, and the doc can no longer be encoded (v14)

1 participant