Skip to content

[lexical] Bug Fix: Skip $reconcileChildren fast path during full reconcile#8564

Merged
etrepum merged 3 commits into
facebook:mainfrom
etrepum:claude/kind-fermat-akGAl
May 26, 2026
Merged

[lexical] Bug Fix: Skip $reconcileChildren fast path during full reconcile#8564
etrepum merged 3 commits into
facebook:mainfrom
etrepum:claude/kind-fermat-akGAl

Conversation

@etrepum

@etrepum etrepum commented May 26, 2026

Copy link
Copy Markdown
Collaborator

Description

The sizeDelta===0 children fast path walks from prevElement.__first while following the next node map's __next pointers, assuming prev and next children share the same keys in the same order. It gated that assumption on _cloneNotNeeded, but a FULL_RECONCILE (setEditorState, which backs history undo/redo) swaps the node map wholesale without routing changes through getWritable(), leaving _cloneNotNeeded empty even when children differ by key. Undoing a markdown code-block transform produces a same-size child key swap, so the walk reached a next-only key and threw "reconcileNode: prevNode or nextNode does not exist in nodeMap" during reconciliation.

Gate the fast path on !treatAllNodesAsDirty so full reconciles fall through to the general key-diffing path.

Closes #8563

Test plan

New unit tests

…ncile (facebook#8563)

The sizeDelta===0 children fast path walks from prevElement.__first while
following the next node map's __next pointers, assuming prev and next
children share the same keys in the same order. It gated that assumption on
_cloneNotNeeded, but a FULL_RECONCILE (setEditorState, which backs history
undo/redo) swaps the node map wholesale without routing changes through
getWritable(), leaving _cloneNotNeeded empty even when children differ by
key. Undoing a markdown code-block transform produces a same-size child key
swap, so the walk reached a next-only key and threw "reconcileNode: prevNode
or nextNode does not exist in nodeMap" during reconciliation.

Gate the fast path on !treatAllNodesAsDirty so full reconciles fall through
to the general key-diffing path.

https://claude.ai/code/session_01EAeZ6geVH74SpUrRhY6Z8h
@vercel

vercel Bot commented May 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview, Comment May 26, 2026 1:03am
lexical-playground Ready Ready Preview, Comment May 26, 2026 1:03am

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 26, 2026
@etrepum etrepum added extended-tests Run extended e2e tests on a PR and removed CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. labels May 26, 2026
Manage the editor lifecycle with `using` and move root-element setup/teardown
into a test extension's register function (setRootElement + document.body
cleanup), matching the idiom used by the other reconciler repro tests. The
editor's dispose also calls setRootElement(null), so the whole fixture tears
down at end of scope without an afterEach.

https://claude.ai/code/session_01EAeZ6geVH74SpUrRhY6Z8h
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 26, 2026
…#8563 repro

A detached root element is enough to drive DOM reconciliation for this repro
(the crash is in node-map lookups, not layout), so set it inline and let the
`using` editor's dispose call setRootElement(null). Removes the test extension
and document.body bookkeeping.

https://claude.ai/code/session_01EAeZ6geVH74SpUrRhY6Z8h
@etrepum etrepum added this pull request to the merge queue May 26, 2026
Merged via the queue into facebook:main with commit da26ab2 May 26, 2026
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. extended-tests Run extended e2e tests on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: The editor crashes during reconciliation after Undo command

3 participants