-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
fix: Failed to execute insertBefore on Node #1042
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
fix: Failed to execute insertBefore on Node #1042
Conversation
|
Thank you for the thorough explanation, this must have been super time consuming to figure out, well done! |
ok, good idea |
@Juice10 Sorry for late! generally speaking, id of node in childNodes should go after it in parentNode when taking fullSnapshot. If new fullSnapshot are rebuild based on mirror with such wired ids. The mirror will be mistaken.
|
|
Is this PR ready to be merged? |
YunFeng0817
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your great fix and thorough explanation!


background
@omairnabiel encountered this runtime error a month ago after upgrade to 2.0.0.alpha.2 and reported at slack.
I encountered this error nowadays as well which totally block replay.
how it happens
In image below:
After initialized, seek after the second fullSnapshot(the two fullSnapshot with different structure).
directly cause by
This error is directly caused by: insert a textNode into another textNode
when I dive into
createOrGetNodeI find that thedomMirrorandrrnodeMirrorreturned different node type with the same nodeIddomMirrorreturned a TextNode(causing that insert a textNode into another textNode)rrnodeMirrorreturned a ElementNodeSo, i guess whether domMirror is outdated in some unknown reason
deep in
Then I combed the flow of replay:
addActionand invoked by Timer schedule(requestAnimationFrame) based on timestampusingVirtualDom = trueI find that during applyEventsSynchronously, if there is a fullSnapshot event, it will update
this.mirrorbased on new fullSnapshot, but not rebuild it after this.mirror clearedbefore rebuild a new fullSnapshot:
number of nodes in event.data.node
after rebuild a new fullSnapshot:
I also refer to [email protected]: in replay and rebuild, and you will get a clean idNodeMap every time rebuild