-
Notifications
You must be signed in to change notification settings - Fork 30k
test: the nextjs internal errors should not be caught #67671
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
Merged
huozhi
merged 7 commits into
canary
from
07-11-skip_next_internal_errors_for_onrequesterror
Jul 12, 2024
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
62b51ce
test: the nextjs internal errors should not be caught
huozhi 835834e
rm unrelated files
huozhi a2f031b
skip deployment test
huozhi 84881c5
skip deployment test
huozhi 325bc20
rm force dynamic in root layout
huozhi a57c90a
simplify fetch
huozhi a052062
add missed checking
huozhi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
test/e2e/on-request-error/skip-next-internal-error/app/another/page.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export default function Page() { | ||
| return <p>another</p> | ||
| } |
7 changes: 7 additions & 0 deletions
7
test/e2e/on-request-error/skip-next-internal-error/app/app-route/not-found/route.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { notFound } from 'next/navigation' | ||
|
|
||
| export function GET() { | ||
| notFound() | ||
| } | ||
|
|
||
| export const dynamic = 'force-dynamic' |
7 changes: 7 additions & 0 deletions
7
test/e2e/on-request-error/skip-next-internal-error/app/app-route/redirect/route.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { redirect } from 'next/navigation' | ||
|
|
||
| export function GET() { | ||
| redirect('/another') | ||
| } | ||
|
|
||
| export const dynamic = 'force-dynamic' |
4 changes: 4 additions & 0 deletions
4
test/e2e/on-request-error/skip-next-internal-error/app/client/dynamic-fetch/page.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| export default async function Page() { | ||
| await fetch('https://example.vercel.sh') | ||
| return <p>dynamic page</p> | ||
| } |
3 changes: 3 additions & 0 deletions
3
test/e2e/on-request-error/skip-next-internal-error/app/client/no-ssr/component.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export default function Component() { | ||
| return <p>Component</p> | ||
| } |
11 changes: 11 additions & 0 deletions
11
test/e2e/on-request-error/skip-next-internal-error/app/client/no-ssr/page.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| 'use client' | ||
|
|
||
| import nextDynamic from 'next/dynamic' | ||
|
|
||
| const Component = nextDynamic(() => import('./component')) | ||
|
|
||
| export default function Page() { | ||
| return <Component /> | ||
| } | ||
|
|
||
| export const dynamic = 'force-dynamic' |
9 changes: 9 additions & 0 deletions
9
test/e2e/on-request-error/skip-next-internal-error/app/client/not-found/page.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| 'use client' | ||
|
|
||
| import { notFound } from 'next/navigation' | ||
|
|
||
| export default function Page() { | ||
| notFound() | ||
| } | ||
|
|
||
| export const dynamic = 'force-dynamic' |
9 changes: 9 additions & 0 deletions
9
test/e2e/on-request-error/skip-next-internal-error/app/client/redirect/page.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| 'use client' | ||
|
|
||
| import { redirect } from 'next/navigation' | ||
|
|
||
| export default function Page() { | ||
| redirect('/another') | ||
| } | ||
|
|
||
| export const dynamic = 'force-dynamic' |
9 changes: 9 additions & 0 deletions
9
test/e2e/on-request-error/skip-next-internal-error/app/layout.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| export default function Layout({ children }) { | ||
| return ( | ||
| <html> | ||
| <body>{children}</body> | ||
| </html> | ||
| ) | ||
| } | ||
|
|
||
| export const dynamic = 'force-dynamic' |
4 changes: 4 additions & 0 deletions
4
test/e2e/on-request-error/skip-next-internal-error/app/server/dynamic-fetch/page.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| export default async function Page() { | ||
| await fetch('https://example.vercel.sh') | ||
| return <p>dynamic page</p> | ||
| } |
7 changes: 7 additions & 0 deletions
7
test/e2e/on-request-error/skip-next-internal-error/app/server/not-found/page.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { notFound } from 'next/navigation' | ||
|
|
||
| export default function Page() { | ||
| notFound() | ||
| } | ||
|
|
||
| export const dynamic = 'force-dynamic' |
7 changes: 7 additions & 0 deletions
7
test/e2e/on-request-error/skip-next-internal-error/app/server/redirect/page.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { redirect } from 'next/navigation' | ||
|
|
||
| export default function Page() { | ||
| redirect('/another') | ||
| } | ||
|
|
||
| export const dynamic = 'force-dynamic' |
3 changes: 3 additions & 0 deletions
3
test/e2e/on-request-error/skip-next-internal-error/instrumentation.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export function onRequestError(err, request, context) { | ||
| console.log('[instrumentation]:error', err.message) | ||
| } |
5 changes: 5 additions & 0 deletions
5
test/e2e/on-request-error/skip-next-internal-error/next.config.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| module.exports = { | ||
| experimental: { | ||
| instrumentationHook: true, | ||
| }, | ||
| } |
82 changes: 82 additions & 0 deletions
82
test/e2e/on-request-error/skip-next-internal-error/skip-next-internal-error.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| import { nextTestSetup } from 'e2e-utils' | ||
|
|
||
| describe('on-request-error - skip-next-internal-error', () => { | ||
| const { next, skipped } = nextTestSetup({ | ||
| files: __dirname, | ||
| skipDeployment: true, | ||
| env: { | ||
| __NEXT_EXPERIMENTAL_INSTRUMENTATION: '1', | ||
| }, | ||
| }) | ||
|
|
||
| if (skipped) { | ||
| return | ||
| } | ||
|
|
||
| async function assertNoNextjsInternalErrors() { | ||
huozhi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const output = next.cliOutput | ||
| // No navigation errors | ||
| expect(output).not.toContain('NEXT_REDIRECT') | ||
| expect(output).not.toContain('NEXT_NOT_FOUND') | ||
| expect(output).not.toContain('BAILOUT_TO_CLIENT_SIDE_RENDERING') | ||
| // No dynamic usage errors | ||
| expect(output).not.toContain('DYNAMIC_SERVER_USAGE') | ||
| // No react postpone errors | ||
| // TODO: cover PPR errors later | ||
| expect(output).not.toContain('react.postpone') | ||
| } | ||
|
|
||
| describe('app router render', () => { | ||
| // Server navigation errors | ||
| it('should not catch server component not-found errors', async () => { | ||
| await next.fetch('/server/not-found') | ||
| await assertNoNextjsInternalErrors() | ||
| }) | ||
|
|
||
| it('should not catch server component redirect errors', async () => { | ||
| await next.render('/server/redirect') | ||
| await assertNoNextjsInternalErrors() | ||
| }) | ||
|
|
||
| // Client navigation errors | ||
| it('should not catch client component not-found errors', async () => { | ||
| await next.fetch('/server/not-found') | ||
| await assertNoNextjsInternalErrors() | ||
| }) | ||
|
|
||
| it('should not catch client component redirect errors', async () => { | ||
| await next.render('/client/redirect') | ||
| await assertNoNextjsInternalErrors() | ||
| }) | ||
|
|
||
| // Dynamic usage | ||
| it('should not catch server component dynamic usage errors', async () => { | ||
| await next.fetch('/server/dynamic-fetch') | ||
| await assertNoNextjsInternalErrors() | ||
| }) | ||
|
|
||
| it('should not catch client component dynamic usage errors', async () => { | ||
| await next.fetch('/client/dynamic-fetch') | ||
| await assertNoNextjsInternalErrors() | ||
| }) | ||
|
|
||
| // No SSR | ||
| it('should not catch next dynamic no-ssr errors', async () => { | ||
| await next.fetch('/client/no-ssr') | ||
| await assertNoNextjsInternalErrors() | ||
| }) | ||
| }) | ||
|
|
||
| describe('app router API', () => { | ||
| // API routes navigation errors | ||
| it('should not catch server component not-found errors', async () => { | ||
| await next.render('/app-route/not-found') | ||
| await assertNoNextjsInternalErrors() | ||
| }) | ||
|
|
||
| it('should not catch server component redirect errors', async () => { | ||
| await next.render('/app-route/redirect') | ||
| await assertNoNextjsInternalErrors() | ||
| }) | ||
| }) | ||
| }) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.