Skip to content

Commit 71797c8

Browse files
authored
[Fizz] Ignore error if content node is gone (facebook#33068)
We normally expect the segment to exist whatever the client does while streaming. However, when hydration errors at the root of the shell for a whole document render, then we clear nodes from body which can include our segments. We don't need them anymore because we switched to client rendering. It triggers an error accessing parent node which can safely be ignored. This just helps avoid confusion in this scenario. This also covers up the error in facebook#33067. Which doesn't actually cause any visible problems other than error logging. However, ideally we wouldn't emit completeBoundary instructions if the boundary is inside a cancelled fallback.
1 parent 9d795d3 commit 71797c8

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

packages/react-dom-bindings/src/server/fizz-instruction-set/ReactDOMFizzInstructionSetInlineCodeStrings.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/react-dom-bindings/src/server/fizz-instruction-set/ReactDOMFizzInstructionSetShared.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ export function clientRenderBoundary(
4949

5050
export function completeBoundary(suspenseBoundaryID, contentID, errorDigest) {
5151
const contentNode = document.getElementById(contentID);
52+
if (!contentNode) {
53+
// If the client has failed hydration we may have already deleted the streaming
54+
// segments. The server may also have emitted a complete instruction but cancelled
55+
// the segment. Regardless we can ignore this case.
56+
return;
57+
}
5258
// We'll detach the content node so that regardless of what happens next we don't leave in the tree.
5359
// This might also help by not causing recalcing each time we move a child from here to the target.
5460
contentNode.parentNode.removeChild(contentNode);

0 commit comments

Comments
 (0)