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

Don't show error overlay for not found and redirect #41438

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/next/client/components/layout-router.tsx
Expand Up @@ -348,7 +348,12 @@ class NotFoundErrorBoundary extends React.Component<

render() {
if (this.state.notFoundTriggered) {
return this.props.notFound
return (
<>
<meta name="robots" content="noindex" />
{this.props.notFound}
</>
)
}

return this.props.children
Expand Down
Expand Up @@ -432,6 +432,13 @@ export default function HotReload({
})

const handleOnUnhandledError = useCallback((ev) => {
if (
ev?.error?.digest.startsWith('NEXT_REDIRECT') ||
ev?.error?.digest === 'NEXT_NOT_FOUND'
) {
ev.preventDefault()
return
}
hadRuntimeError = true
onUnhandledError(dispatch, ev)
}, [])
Expand Down
15 changes: 15 additions & 0 deletions test/e2e/app-dir/index.test.ts
Expand Up @@ -1693,13 +1693,23 @@ describe('app dir', () => {
expect(
await browser.waitForElementByCss('#not-found-component').text()
).toBe('Not Found!')
expect(
await browser
.waitForElementByCss('meta[name="robots"]')
.getAttribute('content')
).toBe('noindex')
})

it.skip('should trigger not-found in a client component', async () => {
const browser = await webdriver(next.url, '/not-found/clientcomponent')
expect(
await browser.waitForElementByCss('#not-found-component').text()
).toBe('Not Found!')
expect(
await browser
.waitForElementByCss('meta[name="robots"]')
.getAttribute('content')
).toBe('noindex')
})
;(isDev ? it.skip : it)(
'should trigger not-found client-side',
Expand All @@ -1712,6 +1722,11 @@ describe('app dir', () => {
expect(
await browser.elementByCss('#not-found-component').text()
).toBe('Not Found!')
expect(
await browser
.waitForElementByCss('meta[name="robots"]')
.getAttribute('content')
).toBe('noindex')
}
)
})
Expand Down