Skip to content

Commit

Permalink
Remove errorHydratingContainer (#28664)
Browse files Browse the repository at this point in the history
I originally added this in #21021 but I didn't mention why and I don't
quite remember why. Maybe because there were no other message? However
at the time the recoverable errors mechanism didn't exist.

Today I believe all cases where this happens will trigger another
recoverable error. Namely these two:


https://github.com/facebook/react/blob/9f33f699e4f832971dc0f2047129f832655a3b6d/packages/react-reconciler/src/ReactFiberBeginWork.js#L1442-L1446


https://github.com/facebook/react/blob/9f33f699e4f832971dc0f2047129f832655a3b6d/packages/react-reconciler/src/ReactFiberBeginWork.js#L2962-L2965

Therefore this is just an extra unnecessary log.
  • Loading branch information
sebmarkbage authored Mar 28, 2024
1 parent 9f33f69 commit 323b6e9
Show file tree
Hide file tree
Showing 15 changed files with 150 additions and 370 deletions.
57 changes: 18 additions & 39 deletions packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2406,19 +2406,12 @@ describe('ReactDOMFizzServer', () => {
},
});

await expect(async () => {
// The first paint switches to client rendering due to mismatch
await waitForPaint([
'client',
"Log recoverable error: Hydration failed because the server rendered HTML didn't match the client.",
'Log recoverable error: There was an error while hydrating.',
]);
}).toErrorDev(
[
'Warning: An error occurred during hydration. The server HTML was replaced with client content.',
],
{withoutStack: 1},
);
// The first paint switches to client rendering due to mismatch
await waitForPaint([
'client',
"Log recoverable error: Hydration failed because the server rendered HTML didn't match the client.",
'Log recoverable error: There was an error while hydrating.',
]);
expect(getVisibleChildren(container)).toEqual(<div>client</div>);
});

Expand Down Expand Up @@ -2486,19 +2479,12 @@ describe('ReactDOMFizzServer', () => {
});

// The first paint uses the client due to mismatch forcing client render
await expect(async () => {
// The first paint switches to client rendering due to mismatch
await waitForPaint([
'client',
"Log recoverable error: Hydration failed because the server rendered HTML didn't match the client.",
'Log recoverable error: There was an error while hydrating.',
]);
}).toErrorDev(
[
'Warning: An error occurred during hydration. The server HTML was replaced with client content',
],
{withoutStack: 1},
);
// The first paint switches to client rendering due to mismatch
await waitForPaint([
'client',
"Log recoverable error: Hydration failed because the server rendered HTML didn't match the client.",
'Log recoverable error: There was an error while hydrating.',
]);
expect(getVisibleChildren(container)).toEqual(<div>client</div>);
});

Expand Down Expand Up @@ -2564,16 +2550,11 @@ describe('ReactDOMFizzServer', () => {

// An error logged but instead of surfacing it to the UI, we switched
// to client rendering.
await expect(async () => {
await waitForAll([
'Yay!',
'Hydration error',
'There was an error while hydrating.',
]);
}).toErrorDev(
'An error occurred during hydration. The server HTML was replaced',
{withoutStack: true},
);
await waitForAll([
'Yay!',
'Hydration error',
'There was an error while hydrating.',
]);
expect(getVisibleChildren(container)).toEqual(<span>Yay!</span>);

// The node that's inside the boundary that errored during hydration was
Expand Down Expand Up @@ -6339,9 +6320,7 @@ describe('ReactDOMFizzServer', () => {
errors.push(error);
},
});
await expect(async () => {
await waitForAll([]);
}).toErrorDev(['An error occurred during hydration'], {withoutStack: 1});
await waitForAll([]);
expect(errors.length).toEqual(2);
expect(getVisibleChildren(container)).toEqual(<span />);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,17 +249,10 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
Scheduler.log(normalizeError(error.message));
},
});
await expect(async () => {
await waitForAll([
"Hydration failed because the server rendered HTML didn't match the client.",
'There was an error while hydrating.',
]);
}).toErrorDev(
[
'An error occurred during hydration. The server HTML was replaced with client content.',
],
{withoutStack: 1},
);
await waitForAll([
"Hydration failed because the server rendered HTML didn't match the client.",
'There was an error while hydrating.',
]);
expect(getVisibleChildren(container)).toEqual(
<div>
<span>
Expand Down Expand Up @@ -337,17 +330,10 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
Scheduler.log(normalizeError(error.message));
},
});
await expect(async () => {
await waitForAll([
"Hydration failed because the server rendered HTML didn't match the client.",
'There was an error while hydrating.',
]);
}).toErrorDev(
[
'An error occurred during hydration. The server HTML was replaced with client content.',
],
{withoutStack: 1},
);
await waitForAll([
"Hydration failed because the server rendered HTML didn't match the client.",
'There was an error while hydrating.',
]);
expect(getVisibleChildren(container)).toEqual(
<div>
<span />
Expand Down Expand Up @@ -384,17 +370,10 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
Scheduler.log(normalizeError(error.message));
},
});
await expect(async () => {
await waitForAll([
"Hydration failed because the server rendered HTML didn't match the client.",
'There was an error while hydrating.',
]);
}).toErrorDev(
[
'An error occurred during hydration. The server HTML was replaced with client content.',
],
{withoutStack: 1},
);
await waitForAll([
"Hydration failed because the server rendered HTML didn't match the client.",
'There was an error while hydrating.',
]);
expect(getVisibleChildren(container)).toEqual(
<div>
<span>
Expand Down Expand Up @@ -434,17 +413,10 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
Scheduler.log(normalizeError(error.message));
},
});
await expect(async () => {
await waitForAll([
"Hydration failed because the server rendered HTML didn't match the client.",
'There was an error while hydrating.',
]);
}).toErrorDev(
[
'An error occurred during hydration. The server HTML was replaced with client content.',
],
{withoutStack: 1},
);
await waitForAll([
"Hydration failed because the server rendered HTML didn't match the client.",
'There was an error while hydrating.',
]);
expect(getVisibleChildren(container)).toEqual(
<div>
<span>
Expand Down Expand Up @@ -482,17 +454,10 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
Scheduler.log(normalizeError(error.message));
},
});
await expect(async () => {
await waitForAll([
"Hydration failed because the server rendered HTML didn't match the client.",
'There was an error while hydrating.',
]);
}).toErrorDev(
[
'An error occurred during hydration. The server HTML was replaced with client content.',
],
{withoutStack: 1},
);
await waitForAll([
"Hydration failed because the server rendered HTML didn't match the client.",
'There was an error while hydrating.',
]);
expect(getVisibleChildren(container)).toEqual(
<div>
<span>
Expand Down Expand Up @@ -604,17 +569,10 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
Scheduler.log(normalizeError(error.message));
},
});
await expect(async () => {
await waitForAll([
"Hydration failed because the server rendered HTML didn't match the client.",
'There was an error while hydrating.',
]);
}).toErrorDev(
[
'An error occurred during hydration. The server HTML was replaced with client content.',
],
{withoutStack: 1},
);
await waitForAll([
"Hydration failed because the server rendered HTML didn't match the client.",
'There was an error while hydrating.',
]);
expect(getVisibleChildren(container)).toEqual(
<div>
<p>Client and server</p>
Expand Down Expand Up @@ -649,17 +607,10 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
Scheduler.log(normalizeError(error.message));
},
});
await expect(async () => {
await waitForAll([
"Hydration failed because the server rendered HTML didn't match the client.",
'There was an error while hydrating.',
]);
}).toErrorDev(
[
'An error occurred during hydration. The server HTML was replaced with client content.',
],
{withoutStack: 1},
);
await waitForAll([
"Hydration failed because the server rendered HTML didn't match the client.",
'There was an error while hydrating.',
]);
expect(getVisibleChildren(container)).toEqual(
<div>
<p>Client and server</p>
Expand Down
18 changes: 2 additions & 16 deletions packages/react-dom/src/__tests__/ReactDOMFloat-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6477,14 +6477,7 @@ body {
},
},
);
await expect(async () => {
await waitForAll([]);
}).toErrorDev(
[
'Warning: An error occurred during hydration. The server HTML was replaced with client content.',
],
{withoutStack: 1},
);
await waitForAll([]);
expect(getMeaningfulChildren(document)).toEqual(
<html>
<head>
Expand Down Expand Up @@ -8267,14 +8260,7 @@ background-color: green;
},
);

await expect(async () => {
await waitForAll([]);
}).toErrorDev(
[
'Warning: An error occurred during hydration. The server HTML was replaced with client content.',
],
{withoutStack: 1},
);
await waitForAll([]);
expect(getMeaningfulChildren(document)).toEqual(
<html>
<head>
Expand Down
Loading

0 comments on commit 323b6e9

Please sign in to comment.