Repository navigation
Description
Description
[NOTE]:
This issue appears to be intermittent and has been difficult to reproduce consistently.
- I originally observed the behaviour and have been able to reproduce it only occasionally (approximately 7–8 times out of 30–40 attempts).
- At the time of writing, neither I nor the maintainers have found a reliable set of reproduction steps.
- Based on the code path, I suspect this may be related to a race condition, but this is currently a hypothesis rather than a confirmed root cause.
- If I discover a reliable reproduction scenario or gather additional debugging information, I will update this issue accordingly.
Leaving the issue open so future observations and debugging information can be collected.
Found while investigating #76402. This is a related but separate bug — filing separately since it has its own distinct root cause and a small, isolated fix.
Root cause: in _applyPersistedCrdtDoc (packages/sync/src/manager.ts), when blocks is invalidated, the fix reads record['blocks'] — always undefined since REST records only expose content. That undefined hits crdt.ts's 'blocks' case, which has a correct fallback (re-derive from content) but only takes it if content is also passed — which it isn't, so it wipes-and-rebuilds instead, causing the duplication.
Suggested fix: also pass record.content along when blocks is invalidated, so the existing correct fallback path gets used.
Step-by-step reproduction instructions
Steps to reproduce:
- Enable RTC. Open a published post with a paragraph that says hello.
- Type 123 → hello 123. Don't save.
- Wait ~1 minute (for WP's own server-side autosave to fire).
- Leave without saving, reopen the post — hello 123 resurfaces (matches RTC can cause an unsaved change to persist and cause data loss from the original post #76402), plus a "there is a more recent autosave" notice.
- Click "View the autosave".
Expected: stays hello 123. Actual: becomes hello 123 123, and repeating the cycle keeps stacking duplicates.
Screenshots, screen recording, code snippet
No response
Environment info
No response
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.
- Block
- Classic
- Hybrid (e.g. classic with theme.json)
- Not sure
Activity
giteshsarvaiya commentedon Jul 8, 2026
Working on this and raising a PR soon