Skip to content

Commit 436e026

Browse files
committed
[Real-time Collaboration] Fix sync issue on refresh (#76017)
* Add (passing) e2e reproduction for refresh and disconnect issue * Reproduce the bug by actually typing in the document * Include current doc state as UPDATE in initial queue alongside SYNC_STEP_1 Root Cause: createYjsDoc() in utils.ts calls stateMap.set(VERSION_KEY, CRDT_DOC_VERSION) which creates the first Yjs operation (clock=0) on the new Y.Doc. This happens before registerRoom() attaches the onDocUpdate handler. As a result, this operation is never captured as a regular UPDATE and never individually sent to peers. After a page refresh, User A gets a new client ID. The stateMap.set creates clock=0 under this new ID, but it’s invisible to the sync system. When User A types, all operations start at clock=1+ and depend on clock=0. User B receives the typing updates but can’t integrate them because the missing dependency (clock=0) was never sent. Why it’s flaky: Occasionally, the server triggers a COMPACTION (full state snapshot) that includes clock=0, resolving the issue within the test timeout. When no compaction arrives in time, the test fails. Fix: In registerRoom(), include the current doc state as an UPDATE in the initial queue alongside the SYNC_STEP_1. This ensures any pre-existing operations (like the VERSION_KEY set) are sent to peers when the queue is resumed. * Delay setting state instead of sending duplicative update * Remove comment --------- Co-authored-by: alecgeatches <[email protected]> Co-authored-by: chriszarate <[email protected]> Source: WordPress/gutenberg@dbddb42
1 parent 40d0856 commit 436e026

9 files changed

Lines changed: 172 additions & 169 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ This is a duplicate of the [WordPress/Gutenberg](https://github.com/WordPress/gu
55
You are currently viewing the version build from the source:
66

77
* Branch: `wp/7.0`
8-
* Commit: [WordPress/Gutenberg@`f23578a2e9a`](https://github.com/WordPress/gutenberg/commit/f23578a2e9a23c5518bce93aaac34330e8afefd5), [Browse files](https://github.com/WordPress/gutenberg/tree/f23578a2e9a23c5518bce93aaac34330e8afefd5)
8+
* Commit: [WordPress/Gutenberg@`dbddb42003c`](https://github.com/WordPress/gutenberg/commit/dbddb42003cf34944b69e4c58725566a96bcddfa), [Browse files](https://github.com/WordPress/gutenberg/tree/dbddb42003cf34944b69e4c58725566a96bcddfa)
99

1010
> [!NOTE]
1111
> This readme file has replaced the original version included in the upstream repository.
1212
>
13-
> The [original `README.md` file](https://github.com/WordPress/gutenberg/blob/f23578a2e9a23c5518bce93aaac34330e8afefd5/README.md) file for this commit can be found in the upstream repository.
13+
> The [original `README.md` file](https://github.com/WordPress/gutenberg/blob/dbddb42003cf34944b69e4c58725566a96bcddfa/README.md) file for this commit can be found in the upstream repository.
1414
1515
## Pupose
1616

build/modules/registry.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,14 @@
1313
'asset' => 'interactivity/index.min.asset.php',
1414
),
1515
array(
16-
'id' => '@wordpress/a11y',
17-
'path' => 'a11y/index',
18-
'asset' => 'a11y/index.min.asset.php',
16+
'id' => '@wordpress/interactivity-router',
17+
'path' => 'interactivity-router/index',
18+
'asset' => 'interactivity-router/index.min.asset.php',
19+
),
20+
array(
21+
'id' => '@wordpress/interactivity-router/full-page',
22+
'path' => 'interactivity-router/full-page',
23+
'asset' => 'interactivity-router/full-page.min.asset.php',
1924
),
2025
array(
2126
'id' => '@wordpress/latex-to-mathml',
@@ -27,16 +32,6 @@
2732
'path' => 'latex-to-mathml/loader',
2833
'asset' => 'latex-to-mathml/loader.min.asset.php',
2934
),
30-
array(
31-
'id' => '@wordpress/interactivity-router',
32-
'path' => 'interactivity-router/index',
33-
'asset' => 'interactivity-router/index.min.asset.php',
34-
),
35-
array(
36-
'id' => '@wordpress/interactivity-router/full-page',
37-
'path' => 'interactivity-router/full-page',
38-
'asset' => 'interactivity-router/full-page.min.asset.php',
39-
),
4035
array(
4136
'id' => '@wordpress/vips/worker',
4237
'path' => 'vips/worker',
@@ -47,21 +42,26 @@
4742
'path' => 'vips/loader',
4843
'asset' => 'vips/loader.min.asset.php',
4944
),
45+
array(
46+
'id' => '@wordpress/a11y',
47+
'path' => 'a11y/index',
48+
'asset' => 'a11y/index.min.asset.php',
49+
),
5050
array(
5151
'id' => '@wordpress/abilities',
5252
'path' => 'abilities/index',
5353
'asset' => 'abilities/index.min.asset.php',
5454
),
55-
array(
56-
'id' => '@wordpress/route',
57-
'path' => 'route/index',
58-
'asset' => 'route/index.min.asset.php',
59-
),
6055
array(
6156
'id' => '@wordpress/core-abilities',
6257
'path' => 'core-abilities/index',
6358
'asset' => 'core-abilities/index.min.asset.php',
6459
),
60+
array(
61+
'id' => '@wordpress/route',
62+
'path' => 'route/index',
63+
'asset' => 'route/index.min.asset.php',
64+
),
6565
array(
6666
'id' => '@wordpress/connectors',
6767
'path' => 'connectors/index',

0 commit comments

Comments
 (0)