You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
RTC can cause an unsaved change to persist and cause data loss from the original post #76402
It appears that an unsaved change can become "sticky" in the editor and prevent a user from being able to edit a post at its currently published state.
When this happens it's not clear how I can return to editing the post at its currently published state, and it's also not clear that a modified version of the post is being edited as opposed to the original.
Step-by-step reproduction instructions
Edit a published post
Make a change but do not save it
Navigate away (dismiss the browser confirmation as necessary)
Navigate back to the editor for that post and observe that your change persists
Depending on how quickly you return to the editor you may see your own avatar position at the point where you made a change.
Screenshots, screen recording, code snippet
You can repeat the process and easily end up with several of your own avatars on the editing screen:
Environment info
WordPress 7.0 beta 4
This can be reproduced on the make.wordpress.org sites too.
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
Please confirm which theme type you used for testing.
I reproduced this, plus found a related bug from the same root cause. Sharing both here since they're connected.
Case 1. Core bug — matches this issue exactly
Steps:
Make sure Real-Time Collaboration is enabled.
Open an existing published post. Note its current content — e.g. a paragraph that just says hello.
Click into that paragraph and type 123, so it now reads hello 123.
Do not click Save/Update. Just leave the tab open for a few seconds (long enough for RTC's background sync to fire — a handful of seconds of inactivity is enough).
Navigate away from the editor (e.g. back to the Posts list). If a browser "leave site / unsaved changes" prompt appears, confirm leaving.
Reopen the same post in the editor.
Expected: the paragraph shows hello (the actual published content). Actual: the paragraph shows hello 123 — the edit you never saved is back, as if it had been saved.
Cause: RTC saves the full editor state to post meta (_crdt_document) continuously as you type, independently of clicking Save. Nothing clears that saved state when you leave without saving, so it gets replayed the next time you open the post.
Case 2. Same bug, compounds with more typing
Steps:
Repeat steps 1-3 above (hello → hello 123).
This time, wait about a minute before doing anything else (long enough for WordPress's own separate autosave to also fire in the background).
Type 123 again, so the paragraph now reads hello 123 123.
Leave the page immediately without saving.
Reopen the post.
Result: shows hello 123 123. Same bug as case 1 — just confirms it's consistent and reflects whatever was last typed, no matter how much editing happened.
Case 3. Related but separate: restoring the server-side autosave makes it worse
Not part of the original report, but found while testing case 1. Note: WordPress actually has two separate autosave notices — a browser-local one ("The backup of this post in your browser is different...") and a server-side one ("There is an autosave of this post that is more recent..."). Restoring the browser-local backup works fine and doesn't show this bug. It's specifically the server-side autosave restore that causes it:
Steps:
Follow case 1's steps until you reopen the post and see the resurfaced hello 123.
At this point WordPress also shows its own, separate "there is a more recent autosave" notice (this is a normal WordPress feature, unrelated to RTC on its own).
Click the "View the autosave" link/button in that notice.
Result:hello 123 becomes hello 123 123 — an extra copy gets added. If you repeat the whole cycle again (edit, leave, reopen, restore the autosave again), it adds yet another copy (hello 123 123 123, and so on).
Cause: clicking "View the autosave" loads a second, separately-saved copy of the same edit (WordPress's own server-side autosave, captured independently of RTC). When that gets combined with RTC's already-saved state, the two aren't recognized as the same edit — instead of merging cleanly, the edit gets added again.
Summary
case 1 matches what's described in this issue.
case 2 is the same bug as case 1, just repeated to confirm it's consistent.
case 3 is a related but separate bug found during testing — happy to file it separately if that's preferred.
I'm looking into a fix — more in the next comment.
@maxschmeling@ellatrix@mmtr — flagging that I've been digging into this (details
in the comment above — case 1 is the one that matches this issue exactly; case 3 is
a related finding from the same investigation, maybe we can open a new issue for it).
Case 1 appears to stem from _applyPersistedCrdtDoc unconditionally replaying
persisted CRDT state on load via Y.applyUpdateV2, with no check for whether that
state was ever actually saved or discarded. I've confirmed this mutation happens,
but haven't yet fully traced how it propagates into what's rendered in the editor —
still working through that.
Separately, I found a concrete, isolated bug that looks related to case 3's
duplication: in the same function's reconciliation step, when 'blocks' comes back
as an invalidated key, it does changes[key] = record[key] — but REST post records
don't expose a blocks field (only content), so this always evaluates to undefined and wipes the CRDT blocks array instead of correctly restoring it. This
part is confirmed by reading the code; I haven't yet confirmed via a debugger/test
that it's the full explanation for the compounding duplication, just that it's a
real bug in that path.
I'd like to start with that isolated record['blocks'] fix first (small, clearly
scoped, easy to write a regression test for), then dig further into case 1's
resurfacing with an eye toward discard-driven cleanup of the persisted _crdt_document meta — but want to nail down the exact mechanism with a test before
proposing that fix.
Let me know if there's a preferred approach, known constraints, or in-flight work I
should be aware of first.
Hi @maxschmeling@ellatrix@mmtr ,
Filed the Case 3 duplication bug separately as #80004 (distinct root cause, small isolated fix) and opened a PR for it: #80011
To be clear — this doesn't address the core issue described here (Case 1, the unsaved-edit resurfacing on reopen); that's still the unconditional CRDT replay-on-load issue, and I'm holding off proposing a fix for that until I can nail down the exact mechanism with a test, or hear back on preferred approach.
Since the collaborative editing feature has been punted from the 7.1 release, I would like to change the status of this issue on the project board accordingly.
Activity
t-hamano commentedon May 8, 2026
Real-time collaboration will not ship in WordPress 7.0, so let's punt this to 7.1.
giteshsarvaiya commentedon Jul 1, 2026
Reproduction notes
I reproduced this, plus found a related bug from the same root cause. Sharing both here since they're connected.
Case 1. Core bug — matches this issue exactly
Steps:
hello.123, so it now readshello 123.Expected: the paragraph shows
hello(the actual published content).Actual: the paragraph shows
hello 123— the edit you never saved is back, as if it had been saved.Cause: RTC saves the full editor state to post meta (
_crdt_document) continuously as you type, independently of clicking Save. Nothing clears that saved state when you leave without saving, so it gets replayed the next time you open the post.Case 2. Same bug, compounds with more typing
Steps:
hello→hello 123).123again, so the paragraph now readshello 123 123.Result: shows
hello 123 123. Same bug as case 1 — just confirms it's consistent and reflects whatever was last typed, no matter how much editing happened.Case 3. Related but separate: restoring the server-side autosave makes it worse
Not part of the original report, but found while testing case 1. Note: WordPress actually has two separate autosave notices — a browser-local one ("The backup of this post in your browser is different...") and a server-side one ("There is an autosave of this post that is more recent..."). Restoring the browser-local backup works fine and doesn't show this bug. It's specifically the server-side autosave restore that causes it:
Steps:
hello 123.Result:
hello 123becomeshello 123 123— an extra copy gets added. If you repeat the whole cycle again (edit, leave, reopen, restore the autosave again), it adds yet another copy (hello 123 123 123, and so on).Cause: clicking "View the autosave" loads a second, separately-saved copy of the same edit (WordPress's own server-side autosave, captured independently of RTC). When that gets combined with RTC's already-saved state, the two aren't recognized as the same edit — instead of merging cleanly, the edit gets added again.
Summary
I'm looking into a fix — more in the next comment.
version: 7.1-alpha-62588
giteshsarvaiya commentedon Jul 1, 2026
@maxschmeling @ellatrix @mmtr — flagging that I've been digging into this (details
in the comment above — case 1 is the one that matches this issue exactly; case 3 is
a related finding from the same investigation, maybe we can open a new issue for it).
Case 1 appears to stem from
_applyPersistedCrdtDocunconditionally replayingpersisted CRDT state on load via
Y.applyUpdateV2, with no check for whether thatstate was ever actually saved or discarded. I've confirmed this mutation happens,
but haven't yet fully traced how it propagates into what's rendered in the editor —
still working through that.
Separately, I found a concrete, isolated bug that looks related to case 3's
duplication: in the same function's reconciliation step, when
'blocks'comes backas an invalidated key, it does
changes[key] = record[key]— but REST post recordsdon't expose a
blocksfield (onlycontent), so this always evaluates toundefinedand wipes the CRDT blocks array instead of correctly restoring it. Thispart is confirmed by reading the code; I haven't yet confirmed via a debugger/test
that it's the full explanation for the compounding duplication, just that it's a
real bug in that path.
I'd like to start with that isolated
record['blocks']fix first (small, clearlyscoped, easy to write a regression test for), then dig further into case 1's
resurfacing with an eye toward discard-driven cleanup of the persisted
_crdt_documentmeta — but want to nail down the exact mechanism with a test beforeproposing that fix.
Let me know if there's a preferred approach, known constraints, or in-flight work I
should be aware of first.
giteshsarvaiya commentedon Jul 8, 2026
Hi @maxschmeling @ellatrix @mmtr ,
Filed the Case 3 duplication bug separately as #80004 (distinct root cause, small isolated fix) and opened a PR for it: #80011
To be clear — this doesn't address the core issue described here (Case 1, the unsaved-edit resurfacing on reopen); that's still the unconditional CRDT replay-on-load issue, and I'm holding off proposing a fix for that until I can nail down the exact mechanism with a test, or hear back on preferred approach.
t-hamano commentedon Jul 9, 2026
Since the collaborative editing feature has been punted from the 7.1 release, I would like to change the status of this issue on the project board accordingly.