Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lexical] surface more error details in reconciler #6511

Merged
merged 1 commit into from
Aug 12, 2024
Merged

Conversation

potatowagon
Copy link
Contributor

@potatowagon potatowagon commented Aug 12, 2024

Description

since 25 jul, observing a high number of The node to be replaced/removed is not a child of this node errors, at the following 2 lines where im adding logging. These errors spiked on 6 Aug but have since died down (on its own) to ~ 2 errors a daily

i've not been able to reproduce those errors so surfacing more details in the error msg to get more clues

i made sure to only surface privacy safe details in the error

fix attempt: #6513

Test plan

Screenshot 2024-08-12 at 12 14 54 PM

threw a new error there to emulate the error.

to trigger that line, replace an entire paragraph node, eg. pasting over the entire paragraph node

Screenshot 2024-08-12 at 12 40 25 PM

Copy link

vercel bot commented Aug 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 12, 2024 4:41am
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 12, 2024 4:41am

@facebook-github-bot facebook-github-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 Aug 12, 2024
Copy link

size-limit report 📦

Path Size
lexical - cjs 29.27 KB (0%)
lexical - esm 29.11 KB (0%)
@lexical/rich-text - cjs 37.63 KB (0%)
@lexical/rich-text - esm 30.93 KB (0%)
@lexical/plain-text - cjs 36.21 KB (0%)
@lexical/plain-text - esm 28.27 KB (0%)
@lexical/react - cjs 39.52 KB (-0.13% 🔽)
@lexical/react - esm 32.35 KB (0%)

@@ -501,7 +512,22 @@ function $reconcileChildren(
} else {
const lastDOM = getPrevElementByKeyOrThrow(prevFirstChildKey);
const replacementDOM = $createNode(nextFrstChildKey, null, null);
dom.replaceChild(replacementDOM, lastDOM);
try {
dom.replaceChild(replacementDOM, lastDOM);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

what could cause The node to be replaced is not a child of this node error here?

seems like the error suggest lastDOM is not a child of dom. did it get deleted before this line exec? and how?

@@ -340,7 +340,18 @@ function reconcileElementTerminatingLineBreak(
const element = dom.__lexicalLineBreak;

if (element != null) {
dom.removeChild(element);
try {
dom.removeChild(element);
Copy link
Contributor Author

@potatowagon potatowagon Aug 12, 2024

Choose a reason for hiding this comment

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

what could cause The node to be removed is not a child of this node error here?

is dom.__lexicalLineBreak above deleted or returning outdated value?

} catch (error) {
if (typeof error === 'object' && error != null) {
const msg = `${error.toString()} Parent: ${
dom.tagName
Copy link
Contributor Author

Choose a reason for hiding this comment

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

what are the best practices when logging errors in lexical? any methods to log the sanitised/privacy safe domNode/lexical node/editor state?

Copy link
Member

Choose a reason for hiding this comment

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

@potatowagon we'd use invariant and you can pass any params in, also keep in mind that internally logged errors have a not very generous max length

@potatowagon
Copy link
Contributor Author

funny the extended e2e tests signal didnt show up in the signal box but i can see they ran successfully (no failures) under the Checks (51) at the top of page

https://github.com/facebook/lexical/actions/runs/10352963152

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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants