Skip to content

Commit fbdfcdf

Browse files
committed
Handle new hydration message format
1 parent dcaab1b commit fbdfcdf

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

packages/next/src/client/components/is-hydration-error.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import isError from '../../lib/is-error'
22

33
const hydrationErrorRegex =
4-
/hydration failed|while hydrating|content does not match|did not match|HTML didn't match/i
4+
/hydration failed|while hydrating|content does not match|did not match|HTML didn't match|text didn't match/i
55

66
const reactUnifiedMismatchWarning = `Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client. This can happen if a SSR-ed Client Component used:`
77

88
const reactHydrationStartMessages = [
99
reactUnifiedMismatchWarning,
10+
`Hydration failed because the server rendered text didn't match the client. As a result this tree will be regenerated on the client. This can happen if a SSR-ed Client Component used:`,
1011
`A tree hydrated but some attributes of the server rendered HTML didn't match the client properties. This won't be patched up. This can happen if a SSR-ed Client Component used:`,
1112
]
1213

test/development/acceptance-app/hydration-error.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ describe('Error overlay for hydration errors in App router', () => {
7373

7474
expect(await getRedboxTotalErrorCount(browser)).toBe(1)
7575

76+
// TODO(veil): Should be "rendered text"
7677
expect(await session.getRedboxDescription()).toMatchInlineSnapshot(
7778
`"Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client. This can happen if a SSR-ed Client Component used:"`
7879
)

test/production/allow-development-build/allow-development-build.test.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,14 @@ describe('allow-development-build', () => {
3737
expect.arrayContaining([
3838
{
3939
message: expect.toBeOneOf([
40-
expect.stringContaining(
41-
"Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client."
42-
),
40+
expect.toBeOneOf([
41+
expect.stringContaining(
42+
"Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client."
43+
),
44+
expect.stringContaining(
45+
"Hydration failed because the server rendered text didn't match the client. As a result this tree will be regenerated on the client."
46+
),
47+
]),
4348
expect.stringContaining(
4449
'There was an error while hydrating. Because the error happened outside of a Suspense boundary, the entire root will switch to client rendering.'
4550
),

0 commit comments

Comments
 (0)