Skip to content

Backport compaction processing fix that can cause user YDocs to diverge#11716

Closed
alecgeatches wants to merge 4 commits intoWordPress:trunkfrom
alecgeatches:backport/rtc-compaction-fix
Closed

Backport compaction processing fix that can cause user YDocs to diverge#11716
alecgeatches wants to merge 4 commits intoWordPress:trunkfrom
alecgeatches:backport/rtc-compaction-fix

Conversation

@alecgeatches
Copy link
Copy Markdown

@alecgeatches alecgeatches commented May 5, 2026

Backport WordPress/gutenberg#77980 to core. This PR fixes an issue that can happen when two offline users reconnect to the same document:

chaos-merge.mov

When two users edit the same post offline and reconnect at roughly the same time, the second reconnecter's changes silently disappear from the server. Their local state still shows their changes, but no other client ever sees it, and the server-side document is the first reconnecter's state. Because of this, the second user is stuck in a non-convergent local YDoc.

The root cause is in process_sync_update()'s compaction handling. On reconnection, both clients push with the same cursor (the last position they saw before disconnecting). The server applies the first one and then sees has_newer_compaction=true for the second, and drops the second compaction. Because the polling provider resets its queue to a single compaction when updates are present on every poll failure, the second user to reconnect has their local changes dropped and becomes divergent.

We'll also want to merge these same changes into the RTC Table PR or any other RTC table PRs that are finalized.

Trac ticket: https://core.trac.wordpress.org/ticket/64622

Use of AI Tools

AI assistance: Yes
Tool(s): Claude
Model(s): Opus 4.7
Used for: Diagnosing the silent-drop branch, drafting the fix.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props alecgeatches, peterwilsoncc, maxschmeling, joefusco, ramonopoly.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@alecgeatches
Copy link
Copy Markdown
Author

Also see suggested changes to @peterwilsoncc's branch #11599 in this comment.

Copy link
Copy Markdown

@josephfusco josephfusco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Ported the same fix to #11256. Nice catch on the silent drop. Storing as type=update instead makes sense since Yjs handles the overlap.

@josephfusco
Copy link
Copy Markdown

Ported this fix to #11256 — thanks @alecgeatches.

Copy link
Copy Markdown
Contributor

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me and is testing well following the reproduction steps on the upstream repository.

I've taken the liberty of pushing some coding standards fixes for multiline comments, there are no source code changes in my commits.

@ramonjd
Copy link
Copy Markdown
Member

ramonjd commented May 6, 2026

It'd be handy to get this backport in - it's blocking the Gutenberg CI. Thanks!

Edit: Apologies, I misread. WordPress/gutenberg#77986 unblocks it. Thanks folks, as you were.

@peterwilsoncc
Copy link
Copy Markdown
Contributor

Merged:

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.

5 participants