Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bad script tag in layout hydration error #66998

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export const hydrationErrorState: HydrationErrorState = {}

// https://github.com/facebook/react/blob/main/packages/react-dom/src/__tests__/ReactDOMHydrationDiff-test.js used as a reference
const htmlTagsWarnings = new Set([
'Warning: Cannot render a sync or defer <script> outside the main document without knowing its order. Try adding async="" or moving it into the root <head> tag.%s',
'Warning: In HTML, %s cannot be a child of <%s>.%s\nThis will cause a hydration error.%s',
'Warning: In HTML, %s cannot be a descendant of <%s>.\nThis will cause a hydration error.%s',
'Warning: In HTML, text nodes cannot be a child of <%s>.\nThis will cause a hydration error.',
Expand Down
30 changes: 21 additions & 9 deletions test/development/acceptance-app/hydration-error.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -720,16 +720,28 @@ describe('Error overlay for hydration errors', () => {
expect(await getRedboxTotalErrorCount(browser)).toBe(1)

const description = await session.getRedboxDescription()
// FIXME
expect(description).toContain(
"TypeError: Cannot read properties of undefined (reading 'replace')"
)
expect(description).toEqual(outdent`
In HTML, <script> cannot be a child of <html>.
This will cause a hydration error.
`)

// const pseudoHtml = await session.getRedboxComponentStack()
// expect(pseudoHtml).toEqual(outdent`
// <script>
// ^^^^^^^^
// `)
const pseudoHtml = await session.getRedboxComponentStack()
if (isTurbopack) {
expect(pseudoHtml).toEqual(outdent`
...
<Layout>
<html>
^^^^^^
<Script>
<script>
^^^^^^^^
`)
} else {
expect(pseudoHtml).toEqual(outdent`
<script>
^^^^^^^^
`)
}
await cleanup()
})

Expand Down
Loading