Fix reconciler recovery listeners #4654
Merged
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.
When reconciler fails we try to recover editor by reseting it to empty state and then doing full reconciliation for
pendingEditorState
. If that goes through, we trigger listeners but the problem is that since we reset editor during recoveryprevEditorState
will be empty, while it's expected to be whatever state was before changes that caused reconciler failre. This PR adjustscommitPendingUpdates
to ensure it uses proper prevEditorState for those listeners.This issue affecting collab in its worst way since collab heavily relies on
prevEditorState
from update listener to calculate Yjs changes for dirty nodes. And since in reconciler recovery scenario prev state is empty, collab assumes that all mutated nodes didn't exist before and re-inserts them causing content duplication. Here's an example of MentionNode that has error thrown insideupdateDOM
method:Screen.Recording.2023-06-13.at.2.33.55.PM.mov