Repository navigation
Conversation
Structs can be integrated past a clock gap of their client, so integrateStructs can't assume that the structs of a client in an update depend on each other. - Only jump to the struct reader of a missing struct if its next struct can contain the missing clock. Before, the stack could end in a cycle and record the wrong client in pendingStructs.missing, so the pending structs were never retried. - Move only the struct that can't be applied to the pending update, not all later structs of its client. Before, whether a struct was integrated depended on how updates were batched, and a document could differ from a document loaded from its own encoding. - Record the missing id in pendingStructs.missing. Retry when the update integrated a struct of that client, or when the missing id is in the store and not in a skip.
zurfyx
force-pushed
the
fix/pending-struct-gaps
branch
from
November 6, 2026 15:40
468b3c9 to
a5bc2e4
Compare
zurfyx
added a commit
to meta/lexical
that referenced
this pull request
Nov 7, 2026
…roblem instead of refusing it ## Description `@lexical/y`'s loaders repair stored states around an encoding problem in `@y/y` 14.0.0-rc.29: a struct stored behind a blocked struct of its client is held pending on load, so a reload drops text the encoding document showed (yjs/yjs#824, D112). The development-only gap probe in the Yjs contract checks the repair's assumptions on scratch documents, and its first check was "a batched struct behind a blocked one is held pending". A `@y/y` that fixes the problem (as yjs/yjs#827 does) failed that check, so development builds threw `YUnsupportedYjsError` for it while production builds, which do not run the gap probe, ran it. Nothing told maintainers that the repair could be removed. The probe now tells the two behaviours apart (feature detection): - `@y/y` holds the batched struct pending: the repair is needed, and every check of what it reads runs as before. - `@y/y` integrates it itself: the probe checks that it behaves as a fixed encoding does (only the blocked structs stay pending, the document reloads from its own encoding as it shows, and, with the repair run on it, the document converges once the missing updates arrive). If so, the probe passes, records the repair as retirable and logs a development-only `console.warn` saying this `@y/y` appears to have the fix. Otherwise it reports a new finding. The probe decodes only bytes that `@y/y` encoded itself, so it does not establish D112's removal condition (states stored with the old batching); that is checked when the repair is removed. - Anything else is still refused. A throw is wrong for users here: their `@y/y` loads stored states correctly. The probe runs before any editor exists, so there is no `onWarn` to route a typed warning through. The maintainer signal is a new contract test, "the installed @y/y still needs the loader repair": the bump to a fixed `@y/y` fails it, which is the cue to remove the repair under D112's condition. The repair itself stays on in every build; on a fixed `@y/y` it finds nothing to integrate. Until a `@y/y` release contains the upstream fix, the repair stays, documented as temporary in the code: `LoadFully.ts`'s module header names the bug (yjs/yjs#824) and the upstream fix (yjs/yjs#827), says the module exists only until a supported `@y/y` release contains it, and lists the removal steps (the signal from the contract test, D112's check against stored states, the modules and tests to delete, the plain `applyUpdate` that replaces each entry point, and the docs and decision rows to update). The entry points (`applyStoredState`, `integrateHeldBehindGaps`, `integrateHeldBehindGapsWith`) point to it. Recorded as D114 in DECISIONS.md, with a pointer from D112. The new tests sit with the other probe tests in `YjsContract.test.ts` rather than under `regressions/`, since they test the probe. Size: the production bundles are byte-identical before and after (`pnpm run build --prod`, every `packages/lexical-y/dist/*.prod.js` compared with `cmp`). `LexicalY.prod.js` stays 369,204 bytes, 113,816 gzip -9. Only the development bundles grow, by the probe code: `LexicalY.dev.js` 342,995 -> 343,704 gzip -9 (+709). ## Changeset `.changeset/y-gap-repair-retirable.md` (`[fix]`, `@lexical/y` patch): development builds no longer throw for a `@y/y` with the fix. ## Test plan ### Before The probe on a simulated fixed `@y/y` (the installed one, with each `applyUpdate` followed by the repair, which integrates what a fixed decode does), on main: ``` $ pnpm exec vitest run --project unit <scratch test calling probeYjs(fixedYjs)> ["gap repair: a batched struct behind a blocked one is not held pending","StructStore.pendingStructs (not made)","decodeUpdateV2 (not made)"] ``` The same on the real upstream fix: `@y/y` 14.0.0-rc.29 with yjs/yjs#827's `src/utils/encoding.js` applied, linked as `packages/lexical-y/node_modules/@y/y`, on main: ``` found: ["gap repair: a batched struct behind a blocked one is not held pending","StructStore.pendingStructs (not made)","decodeUpdateV2 (not made)"] ``` Either would throw `YUnsupportedYjsError` from `createYDoc`, the `YBinding` constructor and the headless helpers in a development build. ### After ``` $ pnpm exec vitest run --project unit packages/lexical-y/src/__tests__/unit/YjsContract.test.ts --reporter=verbose ✓ the installed @y/y passes it ✓ the installed @y/y still needs the loader repair ✓ a @y/y with the encoding problem fixed is not refused: the repair is reported retirable ✓ a @y/y that integrates past the gap but not as a fixed encoding does is found ✓ a @y/y that integrates past the gap but keeps an integrated struct pending is found ✓ a @y/y that integrates past the gap but loses an update while it holds structs pending is found ✓ a @y/y that neither holds a batched struct pending nor integrates it is found ✓ a diffUpdateV2 that ignores the state vector is found ✓ a diffUpdateV2 that ignores the other clients' cuts is found ✓ a format item whose key reads otherwise is found (the format rule reads it) ✓ a @y/y that no longer integrates a struct past a clock gap is found (the plan relies on it) ✓ a mergeUpdatesV2 that drops material is found ✓ a pending update read as format V1 is found ✓ an applyUpdateV2 that does not integrate a lone struct is found Test Files 1 passed (1) Tests 63 passed (63) ``` Each condition of the fixed branch has a test that fails without it: with the pending-clock check removed, "keeps an integrated struct pending" fails; with the reload check removed, "not as a fixed encoding does" fails; with the convergence check removed, "loses an update while it holds structs pending" fails. With the real upstream fix linked as above: ``` @lexical/y: the @y/y the app loaded appears to have the fix for yjs/yjs#824: it loads a struct stored behind a missing one of its client, which @lexical/y's loader repair otherwise does. The loader repair stays on. found: [] status: retirable ``` On that build, `YjsContract.test.ts` fails "the installed @y/y still needs the loader repair" (the intended signal), plus the tests that build their variant on rc.29's own decode or plant broken repair internals (the fixed branch no longer reaches those), and `regressions/LoadAcrossGap.test.ts` fails on its mechanism assertions. All of these go with the repair. Every other `regressions/` file passes. With the supported `@y/y` 14.0.0-rc.29: ``` $ pnpm exec vitest run --project unit packages/lexical-y Test Files 450 passed | 4 skipped (454) Tests 23616 passed | 360 expected fail | 156 skipped (24132) $ pnpm run tsc $ tsc (exit 0) $ pnpm run check-changesets Changeset check passed: 131 pending changeset(s) valid. ``` ESLint and Prettier pass on the changed files. Browser and E2E suites were not run: the change is confined to the development-only probe, which the unit tests exercise.
zurfyx
added a commit
to meta/lexical
that referenced
this pull request
Nov 7, 2026
…roblem instead of refusing it ## Description `@lexical/y`'s loaders repair stored states around an encoding problem in `@y/y` 14.0.0-rc.29: a struct stored behind a blocked struct of its client is held pending on load, so a reload drops text the encoding document showed (yjs/yjs#824, D112). The development-only gap probe in the Yjs contract checks the repair's assumptions on scratch documents, and its first check was "a batched struct behind a blocked one is held pending". A `@y/y` that fixes the problem (as yjs/yjs#827 does) failed that check, so development builds threw `YUnsupportedYjsError` for it while production builds, which do not run the gap probe, ran it. Nothing told maintainers that the repair could be removed. The probe now tells the two behaviours apart (feature detection): - `@y/y` holds the batched struct pending: the repair is needed, and every check of what it reads runs as before. - `@y/y` integrates it itself: the probe checks that it behaves as a fixed encoding does (only the blocked structs stay pending, the document reloads from its own encoding as it shows, the repair, which the loaders still run, does not throw, and the document converges once the missing updates arrive). If so, the probe passes, records the repair as retirable and logs a development-only `console.warn` saying this `@y/y` appears to have the fix. Otherwise it reports a new finding. The probe decodes only bytes that `@y/y` encoded itself, so it does not establish D112's removal condition (states stored with the old batching); that is checked when the repair is removed. - Anything else is still refused. A throw is wrong for users here: their `@y/y` loads stored states correctly. The probe runs before any editor exists, so there is no `onWarn` to route a typed warning through. The maintainer signal is a new contract test, "the installed @y/y still needs the loader repair": the bump to a fixed `@y/y` fails it, which is the cue to remove the repair under D112's condition. The repair itself stays on in every build; on a fixed `@y/y` it finds nothing to integrate. Until a `@y/y` release contains the upstream fix, the repair stays, documented as temporary in the code: `LoadFully.ts`'s module header names the bug (yjs/yjs#824) and the upstream fix (yjs/yjs#827), says the module exists only until a supported `@y/y` release contains it, and lists the removal steps (the signal from the contract test, D112's check against stored states, the modules and tests to delete, the plain `applyUpdate` that replaces each entry point, and the docs and decision rows to update). The entry points (`applyStoredState`, `integrateHeldBehindGaps`, `integrateHeldBehindGapsWith`) point to it. Recorded as D114 in DECISIONS.md, with a pointer from D112. The new tests sit with the other probe tests in `YjsContract.test.ts` rather than under `regressions/`, since they test the probe. Size: the production bundles are byte-identical before and after (`pnpm run build --prod`, every `packages/lexical-y/dist/*.prod.js` compared with `cmp`). `LexicalY.prod.js` stays 369,204 bytes, 113,816 gzip -9. Only the development bundles grow, by the probe code: `LexicalY.dev.js` 342,995 -> 343,704 gzip -9 (+709). ## Changeset `.changeset/y-gap-repair-retirable.md` (`[fix]`, `@lexical/y` patch): development builds no longer throw for a `@y/y` with the fix. ## Test plan ### Before The probe on a simulated fixed `@y/y` (the installed one, with each `applyUpdate` followed by the repair, which integrates what a fixed decode does), on main: ``` $ pnpm exec vitest run --project unit <scratch test calling probeYjs(fixedYjs)> ["gap repair: a batched struct behind a blocked one is not held pending","StructStore.pendingStructs (not made)","decodeUpdateV2 (not made)"] ``` The same on the real upstream fix: `@y/y` 14.0.0-rc.29 with yjs/yjs#827's `src/utils/encoding.js` applied, linked as `packages/lexical-y/node_modules/@y/y`, on main: ``` found: ["gap repair: a batched struct behind a blocked one is not held pending","StructStore.pendingStructs (not made)","decodeUpdateV2 (not made)"] ``` Either would throw `YUnsupportedYjsError` from `createYDoc`, the `YBinding` constructor and the headless helpers in a development build. ### After ``` $ pnpm exec vitest run --project unit packages/lexical-y/src/__tests__/unit/YjsContract.test.ts --reporter=verbose ✓ the installed @y/y passes it ✓ the installed @y/y still needs the loader repair ✓ a @y/y with the encoding problem fixed is not refused: the repair is reported retirable ✓ a @y/y that integrates past the gap but not as a fixed encoding does is found ✓ a @y/y that integrates past the gap but keeps an integrated struct pending is found ✓ a @y/y that integrates past the gap but loses an update while it holds structs pending is found ✓ a @y/y that integrates past the gap but makes the repair throw is found ✓ a @y/y that neither holds a batched struct pending nor integrates it is found ✓ a diffUpdateV2 that ignores the state vector is found ✓ a diffUpdateV2 that ignores the other clients' cuts is found ✓ a format item whose key reads otherwise is found (the format rule reads it) ✓ a @y/y that no longer integrates a struct past a clock gap is found (the plan relies on it) ✓ a mergeUpdatesV2 that drops material is found ✓ a pending update read as format V1 is found ✓ an applyUpdateV2 that does not integrate a lone struct is found Test Files 1 passed (1) Tests 64 passed (64) ``` Each condition of the fixed branch has a test that fails without it: with the pending-clock check removed, "keeps an integrated struct pending" fails; with the reload check removed, "not as a fixed encoding does" fails; with the convergence check removed, "loses an update while it holds structs pending" fails; with the repair run without rethrowing, "makes the repair throw" fails. With the real upstream fix linked as above: ``` @lexical/y: the @y/y the app loaded appears to have the fix for yjs/yjs#824: it loads a struct stored behind a missing one of its client, which @lexical/y's loader repair otherwise does. The loader repair stays on. found: [] status: retirable ``` On that build, `YjsContract.test.ts` fails "the installed @y/y still needs the loader repair" (the intended signal), plus the tests that build their variant on rc.29's own decode or plant broken repair internals (the fixed branch no longer reaches those), and `regressions/LoadAcrossGap.test.ts` fails on its mechanism assertions. All of these go with the repair. Every other `regressions/` file passes. With the supported `@y/y` 14.0.0-rc.29: ``` $ pnpm exec vitest run --project unit packages/lexical-y Test Files 450 passed | 4 skipped (454) Tests 23617 passed | 360 expected fail | 156 skipped (24133) $ pnpm run tsc $ tsc (exit 0) $ pnpm run check-changesets Changeset check passed: 131 pending changeset(s) valid. ``` ESLint and Prettier pass on the changed files. Browser and E2E suites were not run: the change is confined to the development-only probe, which the unit tests exercise.
zurfyx
added a commit
to meta/lexical
that referenced
this pull request
Nov 7, 2026
…roblem instead of refusing it ## Description `@lexical/y`'s loaders repair stored states around an encoding problem in `@y/y` 14.0.0-rc.29: a struct stored behind a blocked struct of its client is held pending on load, so a reload drops text the encoding document showed (yjs/yjs#824, D112). The development-only gap probe in the Yjs contract checks the repair's assumptions on scratch documents, and its first check was "a batched struct behind a blocked one is held pending". A `@y/y` that fixes the problem (as yjs/yjs#827 does) failed that check, so development builds threw `YUnsupportedYjsError` for it while production builds, which do not run the gap probe, ran it. Nothing told maintainers that the repair could be removed. The probe now tells the two behaviours apart (feature detection): - `@y/y` holds the batched struct pending: the repair is needed, and every check of what it reads runs as before. - `@y/y` integrates it itself: the probe checks that it behaves as a fixed encoding does (only the blocked structs stay pending, the document reloads from its own encoding as it shows, the repair, which the loaders still run, does not throw, and the document converges once the missing updates arrive). If so, the probe passes, records the repair as retirable and logs a development-only `console.warn` saying this `@y/y` appears to have the fix. Otherwise it reports a new finding. The probe decodes only bytes that `@y/y` encoded itself, so it does not establish D112's removal condition (states stored with the old batching); that is checked when the repair is removed. - Anything else is still refused. A throw is wrong for users here: their `@y/y` loads stored states correctly. The probe runs before any editor exists, so there is no `onWarn` to route a typed warning through. The maintainer signal is a new contract test, "the installed @y/y still needs the loader repair": the bump to a fixed `@y/y` fails it, which is the cue to remove the repair under D112's condition. The repair itself stays on in every build; on a fixed `@y/y` it finds nothing to integrate. Until a `@y/y` release contains the upstream fix, the repair stays, documented as temporary in the code: `LoadFully.ts`'s module header names the bug (yjs/yjs#824) and the upstream fix (yjs/yjs#827), says the module exists only until a supported `@y/y` release contains it, and lists the removal steps (the signal from the contract test, D112's check against stored states, the modules and tests to delete, the plain `applyUpdate` that replaces each entry point, and the docs and decision rows to update). The entry points (`applyStoredState`, `integrateHeldBehindGaps`, `integrateHeldBehindGapsWith`) point to it. Recorded as D114 in DECISIONS.md, with a pointer from D112. The regression test, `regressions/FixedYjsNotRefused.test.ts`, runs the entry points (`createYDoc`, the `YBinding` constructor, `seedYState`, `readYState`) on a fixed `@y/y`; the probe's own cases sit with the other probe tests in `YjsContract.test.ts`. Size: the production bundles are byte-identical before and after (`pnpm run build --prod`, every `packages/lexical-y/dist/*.prod.js` compared with `cmp`). `LexicalY.prod.js` stays 369,204 bytes, 113,816 gzip -9. Only the development bundles grow, by the probe code: `LexicalY.dev.js` 342,995 -> 343,704 gzip -9 (+709). ## Changeset `.changeset/y-gap-repair-retirable.md` (`[fix]`, `@lexical/y` patch): development builds no longer throw for a `@y/y` with the fix. ## Test plan ### Before The probe on a simulated fixed `@y/y` (the installed one, with each `applyUpdate` followed by the repair, which integrates what a fixed decode does), on main: ``` $ pnpm exec vitest run --project unit <scratch test calling probeYjs(fixedYjs)> ["gap repair: a batched struct behind a blocked one is not held pending","StructStore.pendingStructs (not made)","decodeUpdateV2 (not made)"] ``` The same on the real upstream fix: `@y/y` 14.0.0-rc.29 with yjs/yjs#827's `src/utils/encoding.js` applied, linked as `packages/lexical-y/node_modules/@y/y`, on main: ``` found: ["gap repair: a batched struct behind a blocked one is not held pending","StructStore.pendingStructs (not made)","decodeUpdateV2 (not made)"] ``` Either would throw `YUnsupportedYjsError` from `createYDoc`, the `YBinding` constructor and the headless helpers in a development build. The new regression test, with main's `YjsContract.ts`: ``` $ pnpm exec vitest run --project unit packages/lexical-y/src/__tests__/unit/regressions/FixedYjsNotRefused.test.ts × the entry points run on a @y/y with yjs/yjs#824 fixed, and the check warns once YUnsupportedYjsError: @lexical/y supports exactly @y/y 14.0.0-rc.29, and the @y/y the app loaded differs (gap repair: a batched struct behind a blocked one is not held pending, StructStore.pendingStructs (not made), decodeUpdateV2 (not made)). Install @y/[email protected], once per app. Tests 1 failed (1) ``` ### After ``` $ pnpm exec vitest run --project unit packages/lexical-y/src/__tests__/unit/YjsContract.test.ts --reporter=verbose ✓ the installed @y/y passes it ✓ the installed @y/y still needs the loader repair ✓ a @y/y with the encoding problem fixed is not refused: the repair is reported retirable ✓ a @y/y that integrates past the gap but not as a fixed encoding does is found ✓ a @y/y that integrates past the gap but keeps an integrated struct pending is found ✓ a @y/y that integrates past the gap but keeps the second writer's integrated struct pending is found ✓ a @y/y that integrates past the gap but loses an update while it holds structs pending is found ✓ a @y/y that integrates past the gap but makes the repair throw is found ✓ a @y/y that neither holds a batched struct pending nor integrates it is found ✓ a diffUpdateV2 that ignores the state vector is found ✓ a diffUpdateV2 that ignores the other clients' cuts is found ✓ a format item whose key reads otherwise is found (the format rule reads it) ✓ a @y/y that no longer integrates a struct past a clock gap is found (the plan relies on it) ✓ a mergeUpdatesV2 that drops material is found ✓ a pending update read as format V1 is found ✓ an applyUpdateV2 that does not integrate a lone struct is found Test Files 1 passed (1) Tests 65 passed (65) ``` Each condition of the fixed branch has a test that fails without it: with the pending-clock check removed, "keeps an integrated struct pending" fails, and with the second writer's replaced by the first's, "keeps the second writer's integrated struct pending" fails; with the reload check removed, "not as a fixed encoding does" fails; with the convergence check removed, "loses an update while it holds structs pending" fails; with the repair run without rethrowing, "makes the repair throw" fails. ``` $ pnpm exec vitest run --project unit packages/lexical-y/src/__tests__/unit/regressions/FixedYjsNotRefused.test.ts ✓ the entry points run on a @y/y with yjs/yjs#824 fixed, and the check warns once Tests 1 passed (1) ``` With the real upstream fix linked as above: ``` @lexical/y: the @y/y the app loaded appears to have the fix for yjs/yjs#824: it loads a struct stored behind a missing one of its client, which @lexical/y's loader repair otherwise does. The loader repair stays on. found: [] status: retirable ``` On that build, `YjsContract.test.ts` fails "the installed @y/y still needs the loader repair" (the intended signal), plus the tests that build their variant on rc.29's own decode or plant broken repair internals (the fixed branch no longer reaches those), and `regressions/LoadAcrossGap.test.ts` fails on its mechanism assertions. All of these go with the repair. Every other `regressions/` file passes. With the supported `@y/y` 14.0.0-rc.29: ``` $ pnpm exec vitest run --project unit packages/lexical-y Test Files 451 passed | 4 skipped (455) Tests 23619 passed | 360 expected fail | 156 skipped (24135) $ pnpm run tsc $ tsc (exit 0) $ pnpm run check-changesets Changeset check passed: 131 pending changeset(s) valid. ``` ESLint and Prettier pass on the changed files. Browser and E2E suites were not run: the change is confined to the development-only probe, which the unit tests exercise.
zurfyx
added a commit
to meta/lexical
that referenced
this pull request
Nov 7, 2026
…roblem instead of refusing it ## Description `@lexical/y`'s loaders repair stored states around an encoding problem in `@y/y` 14.0.0-rc.29: a struct stored behind a blocked struct of its client is held pending on load, so a reload drops text the encoding document showed (yjs/yjs#824, D112). The development-only gap probe in the Yjs contract checks the repair's assumptions on scratch documents, and its first check was "a batched struct behind a blocked one is held pending". A `@y/y` that fixes the problem (as yjs/yjs#827 does) failed that check, so development builds threw `YUnsupportedYjsError` for it while production builds, which do not run the gap probe, ran it. Nothing told maintainers that the repair could be removed. The probe now tells the two behaviours apart (feature detection): - `@y/y` holds the batched struct pending: the repair is needed, and every check of what it reads runs as before. - `@y/y` integrates it itself: the probe checks that it behaves as a fixed encoding does (only the blocked structs stay pending, the document reloads from its own encoding as it shows, the repair, which the loaders still run, does not throw, and the document converges once the missing updates arrive). If so, the probe passes, records the repair as retirable and logs a development-only `console.warn` saying this `@y/y` appears to have the fix. Otherwise it reports a new finding. The probe decodes only bytes that `@y/y` encoded itself, so it does not establish D112's removal condition (states stored with the old batching); that is checked when the repair is removed. - Anything else is still refused. A throw is wrong for users here: their `@y/y` loads stored states correctly. The probe runs before any editor exists, so there is no `onWarn` to route a typed warning through. The maintainer signal is a new contract test, "the installed @y/y still needs the loader repair": the bump to a fixed `@y/y` fails it, which is the cue to remove the repair under D112's condition. The repair itself stays on in every build; on a fixed `@y/y` it finds nothing to integrate. Until a `@y/y` release contains the upstream fix, the repair stays, documented as temporary in the code: `LoadFully.ts`'s module header names the bug (yjs/yjs#824) and the upstream fix (yjs/yjs#827), says the module exists only until a supported `@y/y` release contains it, and lists the removal steps (fixtures of states stored under rc.29 kept before the bump, the three `@y/y` pins to bump with the install and `update-version`, the signal from the contract test, D112's check of those fixtures with a plain load, the modules, symbols and tests to delete, the plain `applyUpdate` that replaces each entry point, and the docs and decision rows to update). Following its deletions and replacements in a scratch copy leaves `tsc` with no error in `packages/lexical-y`. The entry points (`applyStoredState`, `integrateHeldBehindGaps`, `integrateHeldBehindGapsWith`) point to it. Recorded as D114 in DECISIONS.md, with a pointer from D112. The regression test, `regressions/FixedYjsNotRefused.test.ts`, runs the entry points (`createYDoc`, the `YBinding` constructor, `seedYState`, `readYState`) on a fixed `@y/y`; the probe's own cases sit with the other probe tests in `YjsContract.test.ts`. Size: the production bundles are byte-identical before and after (`pnpm run build --prod`, every `packages/lexical-y/dist/*.prod.js` compared with `cmp`). `LexicalY.prod.js` stays 369,204 bytes, 113,816 gzip -9. Only the development bundles grow, by the probe code: `LexicalY.dev.js` 342,995 -> 343,704 gzip -9 (+709). ## Changeset `.changeset/y-gap-repair-retirable.md` (`[fix]`, `@lexical/y` patch): development builds no longer throw for a `@y/y` with the fix. ## Test plan ### Before The probe on a simulated fixed `@y/y` (the installed one, with each `applyUpdate` followed by the repair, which integrates what a fixed decode does), on main: ``` $ pnpm exec vitest run --project unit <scratch test calling probeYjs(fixedYjs)> ["gap repair: a batched struct behind a blocked one is not held pending","StructStore.pendingStructs (not made)","decodeUpdateV2 (not made)"] ``` The same on the real upstream fix: `@y/y` 14.0.0-rc.29 with yjs/yjs#827's `src/utils/encoding.js` applied, linked as `packages/lexical-y/node_modules/@y/y`, on main: ``` found: ["gap repair: a batched struct behind a blocked one is not held pending","StructStore.pendingStructs (not made)","decodeUpdateV2 (not made)"] ``` Either would throw `YUnsupportedYjsError` from `createYDoc`, the `YBinding` constructor and the headless helpers in a development build. The new regression test, with main's `YjsContract.ts`: ``` $ pnpm exec vitest run --project unit packages/lexical-y/src/__tests__/unit/regressions/FixedYjsNotRefused.test.ts × the entry points run on a @y/y with yjs/yjs#824 fixed, and the check warns once YUnsupportedYjsError: @lexical/y supports exactly @y/y 14.0.0-rc.29, and the @y/y the app loaded differs (gap repair: a batched struct behind a blocked one is not held pending, StructStore.pendingStructs (not made), decodeUpdateV2 (not made)). Install @y/[email protected], once per app. Tests 1 failed (1) ``` ### After ``` $ pnpm exec vitest run --project unit packages/lexical-y/src/__tests__/unit/YjsContract.test.ts --reporter=verbose ✓ the installed @y/y passes it ✓ the installed @y/y still needs the loader repair ✓ a @y/y with the encoding problem fixed is not refused: the repair is reported retirable ✓ a @y/y that integrates past the gap but not as a fixed encoding does is found ✓ a @y/y that integrates past the gap but keeps an integrated struct pending is found ✓ a @y/y that integrates past the gap but keeps the first writer's integrated struct pending is found ✓ a @y/y that integrates past the gap but keeps the second writer's integrated struct pending is found ✓ a @y/y that integrates past the gap but loses an update while it holds structs pending is found ✓ a @y/y that integrates past the gap but makes the repair throw is found ✓ a @y/y that neither holds a batched struct pending nor integrates it is found ✓ a diffUpdateV2 that ignores the state vector is found ✓ a diffUpdateV2 that ignores the other clients' cuts is found ✓ a format item whose key reads otherwise is found (the format rule reads it) ✓ a @y/y that no longer integrates a struct past a clock gap is found (the plan relies on it) ✓ a mergeUpdatesV2 that drops material is found ✓ a pending update read as format V1 is found ✓ an applyUpdateV2 that does not integrate a lone struct is found Test Files 1 passed (1) Tests 66 passed (66) ``` Each condition of the fixed branch has a test that fails without it: with the first writer's pending-clock check removed, "keeps the first writer's integrated struct pending" fails, and with the second writer's removed, "keeps the second writer's integrated struct pending" fails; with the reload check removed, "not as a fixed encoding does" fails; with the convergence check removed, "loses an update while it holds structs pending" fails; with the repair run without rethrowing, "makes the repair throw" fails. ``` $ pnpm exec vitest run --project unit packages/lexical-y/src/__tests__/unit/regressions/FixedYjsNotRefused.test.ts ✓ the entry points run on a @y/y with yjs/yjs#824 fixed, and the check warns once Tests 1 passed (1) ``` With the real upstream fix linked as above: ``` @lexical/y: the @y/y the app loaded appears to have the fix for yjs/yjs#824: it loads a struct stored behind a missing one of its client, which @lexical/y's loader repair otherwise does. The loader repair stays on. found: [] status: retirable ``` On that build, `YjsContract.test.ts` fails "the installed @y/y still needs the loader repair" (the intended signal), plus the tests that build their variant on rc.29's own decode or plant broken repair internals (the fixed branch no longer reaches those), and `regressions/LoadAcrossGap.test.ts` fails on its mechanism assertions. All of these go with the repair. Every other `regressions/` file passes. With the supported `@y/y` 14.0.0-rc.29: ``` $ pnpm exec vitest run --project unit packages/lexical-y Test Files 451 passed | 4 skipped (455) Tests 23620 passed | 360 expected fail | 156 skipped (24136) $ pnpm run tsc $ tsc (exit 0) $ pnpm run check-changesets Changeset check passed: 131 pending changeset(s) valid. ``` ESLint and Prettier pass on the changed files. Browser and E2E suites were not run: the change is confined to the development-only probe, which the unit tests exercise.
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.
Fixes #824.
Cause. Yjs 14 integrates a struct past a clock gap of its client, but
integrateStructsstill assumed that the structs of one client in an update depend on each other:pendingStructs.missingnames the wrong client ({ 2 => 0 }in the issue), and the pending structs are never retried.Fix (
src/utils/encoding.js):getMissingreturns the missing id. We only jump to the missing client's next struct if it doesn't start after the missing clock.pendingStructs.missingrecords the missing clock.readUpdateV2retries if the update integrated a struct of a missing client, or if the missing id is now in the store and not in a skip.Tests (
tests/updates.tests.js): the repros from the issue, a test for the retry condition, and a randomized test that delivers updates out of order in randommergeUpdatesbatches and checks that every doc equals a doc loaded from its own encoding. I also fuzzed this for 28,000 seeds (together with #826) without failures; main fails 88% of them. Applying updates in order and loading an encoding are as fast as before.testStructPastPendingStructSurvivesReloadchecks that a struct integrated past a pending struct of its client survives a reload fromencodeStateAsUpdate, whether it arrives after or before the pending struct, with gc on and off. It fails on main.npm run lintstops at markdownlint on main (README.md line 143);standardandtscpass.