Skip to content

Commit

Permalink
replace-fork
Browse files Browse the repository at this point in the history
  • Loading branch information
salazarm committed Mar 29, 2022
1 parent 9533ca2 commit 9672f26
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
13 changes: 9 additions & 4 deletions packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js
Expand Up @@ -468,6 +468,9 @@ describe('ReactDOMFizzServer', () => {
onError(x) {
loggedErrors.push(x);
},
getErrorHash() {
return 'Hash';
},
},
);
pipe(writable);
Expand All @@ -494,14 +497,16 @@ describe('ReactDOMFizzServer', () => {

// Now we can client render it instead.
expect(Scheduler).toFlushAndYield([]);
if (__DEV__) {
expectErrors(errors, [
expectErrors(
errors,
[
{
error: theError.message,
componentStack: componentStack(['Lazy', 'Suspense', 'div', 'App']),
},
]);
}
],
['Hash'],
);

// The client rendered HTML is now in place.
expect(getVisibleChildren(container)).toEqual(<div>Hello</div>);
Expand Down
15 changes: 10 additions & 5 deletions packages/react-reconciler/src/ReactFiberBeginWork.old.js
Expand Up @@ -152,6 +152,7 @@ import {
shouldSetTextContent,
isSuspenseInstancePending,
isSuspenseInstanceFallback,
getSuspenseInstanceFallbackError,
registerSuspenseInstanceRetry,
supportsHydration,
isPrimaryRenderer,
Expand Down Expand Up @@ -2689,18 +2690,22 @@ function updateDehydratedSuspenseComponent(
// This boundary is in a permanent fallback state. In this case, we'll never
// get an update and we'll never be able to hydrate the final content. Let's just try the
// client side render instead.
const errorMsg = getSuspenseInstanceFallbackError(suspenseInstance);
return retrySuspenseComponentWithoutHydrating(
current,
workInProgress,
renderLanes,
// TODO: The server should serialize the error message so we can log it
// here on the client. Or, in production, a hash/id that corresponds to
// the error.
new Error(
'The server could not finish this Suspense boundary, likely ' +
'due to an error during server rendering. Switched to ' +
'client rendering.',
),
errorMsg
? // eslint-disable-next-line react-internal/prod-error-codes
new Error(errorMsg)
: new Error(
'The server could not finish this Suspense boundary, likely ' +
'due to an error during server rendering. Switched to ' +
'client rendering.',
),
);
}

Expand Down

0 comments on commit 9672f26

Please sign in to comment.