fix: key HeroSlackMessage body paragraph by message id to prevent removeChild crash #SUPERLOG - #428
Open
superlog-app[bot] wants to merge 1 commit into
Open
fix: key HeroSlackMessage body paragraph by message id to prevent removeChild crash #SUPERLOG#428superlog-app[bot] wants to merge 1 commit into
superlog-app[bot] wants to merge 1 commit into
Conversation
…oveChild crash #SUPERLOG Delivery-Id: e2342e7d51ab9a66c1fa56101fb7f1ca6ae6a6ac5c5fe70b5f5504aeb1ebe0de Delivery-Base: main
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
The homepage (
/) crashes withFailed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.every time the animated Slack card in the hero section rotates (every 2.8 s). TheBrowserErrorBoundarycatches it and renders the error screen, replacing the entire landing page.Root cause
The
HeroSlackMessagecomponent (added in #427) cycles through three message objects viasetActiveMessageIndex, triggered byonAnimationIterationon the CSS-animated.landing-slack-shuffle-carddiv. Each message has abodyfield — a JSX Fragment created at module initialization time (not at render time) — that mixes raw text nodes with<SlackCode>(<code>) elements.Because the
<p>that renders{message.body}has nokeyprop, React reconciles its children in place (positional diffing) when the message changes. The homepage is prerendered (SSR viarenderToString) and then hydrated client-side withhydrateRoot. Mixed text-node/element fragments can have subtle differences in how adjacent text nodes are split between SSR and CSR, leaving React's internal fiber tree slightly out of sync with the real DOM. When the first animation iteration fires and React tries to remove excess old DOM nodes from the<p>, it callsparentNode.removeChild(node)on a node that is no longer at the expected position, producing theNotFoundError.Fix
Add
key={message.id}to the<p>element. When the key changes, React unmounts and remounts the paragraph entirely rather than attempting incremental child reconciliation, eliminating the stale-referenceremoveChildcall.All 14 existing
Landing.test.tstests pass.Incident: c31e760e-d0ec-4e3f-a2b3-2c106c01a7a5
Was this PR helpful? Leave feedback — goes straight to the Superlog team.
Summary by cubic
Fixes a homepage crash when the hero Slack card rotates by preventing a React DOM mismatch. The message paragraph is now keyed by
message.id, so it remounts on change and avoids the removeChild error.Written for commit 5f6a15b. Summary will update on new commits.