Skip to content

Commit ad431e9

Browse files
committed
only send hash if present
1 parent 8d3c13f commit ad431e9

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

packages/react-dom/src/client/ReactDOMHostConfig.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,7 @@ export function getSuspenseInstanceFallbackErrorDetails(
750750
stack,
751751
};
752752
} else {
753+
// Object gets DCE'd if constructed in tail position and matches callsite destructuring
753754
return {
754755
digest,
755756
};

packages/react-dom/src/server/ReactDOMServerFormatConfig.js

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,16 +1527,22 @@ const startClientRenderedSuspenseBoundary = stringToPrecomputedChunk(
15271527
const endSuspenseBoundary = stringToPrecomputedChunk('<!--/$-->');
15281528

15291529
const clientRenderedSuspenseBoundaryError1 = stringToPrecomputedChunk(
1530-
'<template data-dgst="',
1530+
'<template',
1531+
);
1532+
const clientRenderedSuspenseBoundaryErrorAttrInterstitial = stringToPrecomputedChunk(
1533+
'"',
15311534
);
15321535
const clientRenderedSuspenseBoundaryError1A = stringToPrecomputedChunk(
1533-
'" data-msg="',
1536+
' data-dgst="',
15341537
);
15351538
const clientRenderedSuspenseBoundaryError1B = stringToPrecomputedChunk(
1536-
'" data-stck="',
1539+
' data-msg="',
1540+
);
1541+
const clientRenderedSuspenseBoundaryError1C = stringToPrecomputedChunk(
1542+
' data-stck="',
15371543
);
15381544
const clientRenderedSuspenseBoundaryError2 = stringToPrecomputedChunk(
1539-
'"></template>',
1545+
'></template>',
15401546
);
15411547

15421548
export function pushStartCompletedSuspenseBoundary(
@@ -1586,24 +1592,36 @@ export function writeStartClientRenderedSuspenseBoundary(
15861592
startClientRenderedSuspenseBoundary,
15871593
);
15881594
writeChunk(destination, clientRenderedSuspenseBoundaryError1);
1589-
writeChunk(
1590-
destination,
1591-
stringToChunk(escapeTextForBrowser(errorDigest || '')),
1592-
);
1595+
if (errorDigest) {
1596+
writeChunk(destination, clientRenderedSuspenseBoundaryError1A);
1597+
writeChunk(destination, stringToChunk(escapeTextForBrowser(errorDigest)));
1598+
writeChunk(
1599+
destination,
1600+
clientRenderedSuspenseBoundaryErrorAttrInterstitial,
1601+
);
1602+
}
15931603
if (__DEV__) {
15941604
if (errorMesssage) {
1595-
writeChunk(destination, clientRenderedSuspenseBoundaryError1A);
1605+
writeChunk(destination, clientRenderedSuspenseBoundaryError1B);
15961606
writeChunk(
15971607
destination,
15981608
stringToChunk(escapeTextForBrowser(errorMesssage)),
15991609
);
1610+
writeChunk(
1611+
destination,
1612+
clientRenderedSuspenseBoundaryErrorAttrInterstitial,
1613+
);
16001614
}
16011615
if (errorComponentStack) {
1602-
writeChunk(destination, clientRenderedSuspenseBoundaryError1B);
1616+
writeChunk(destination, clientRenderedSuspenseBoundaryError1C);
16031617
writeChunk(
16041618
destination,
16051619
stringToChunk(escapeTextForBrowser(errorComponentStack)),
16061620
);
1621+
writeChunk(
1622+
destination,
1623+
clientRenderedSuspenseBoundaryErrorAttrInterstitial,
1624+
);
16071625
}
16081626
}
16091627
result = writeChunkAndReturn(

0 commit comments

Comments
 (0)