-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expand
server-source-maps
scenarios to cover Edge runtime
...and use test patterns more consistently
- Loading branch information
Showing
20 changed files
with
286 additions
and
143 deletions.
There are no files selected for viewing
39 changes: 0 additions & 39 deletions
39
test/development/app-render-error-log/app-render-error-log.test.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
6 changes: 5 additions & 1 deletion
6
test/e2e/app-dir/server-source-maps/fixtures/default/app/layout.js
This file contains 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 |
---|---|---|
@@ -1,7 +1,11 @@ | ||
import { Suspense } from 'react' | ||
|
||
export default function Root({ children }) { | ||
return ( | ||
<html> | ||
<body>{children}</body> | ||
<body> | ||
<Suspense>{children}</Suspense> | ||
</body> | ||
</html> | ||
) | ||
} |
6 changes: 5 additions & 1 deletion
6
test/e2e/app-dir/server-source-maps/fixtures/default/app/rsc-error-log-cause/page.js
This file contains 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
6 changes: 5 additions & 1 deletion
6
test/e2e/app-dir/server-source-maps/fixtures/default/app/rsc-error-log-custom-name/page.js
This file contains 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
5 changes: 4 additions & 1 deletion
5
test/e2e/app-dir/server-source-maps/fixtures/default/app/rsc-error-log-ignore-listed/page.js
This file contains 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 |
---|---|---|
@@ -1,11 +1,14 @@ | ||
import { connection } from 'next/server' | ||
import { run } from 'internal-pkg' | ||
|
||
function logError() { | ||
const error = new Error('Boom') | ||
console.error(error) | ||
} | ||
|
||
export default function Page() { | ||
export default async function Page() { | ||
await connection() | ||
|
||
run(() => logError()) | ||
return null | ||
} |
6 changes: 5 additions & 1 deletion
6
test/e2e/app-dir/server-source-maps/fixtures/default/app/rsc-error-log/page.js
This file contains 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 |
---|---|---|
@@ -1,9 +1,13 @@ | ||
import { connection } from 'next/server' | ||
|
||
function logError() { | ||
const error = new Error('Boom') | ||
console.error(error) | ||
} | ||
|
||
export default function Page() { | ||
export default async function Page() { | ||
await connection() | ||
|
||
logError() | ||
return null | ||
} |
9 changes: 9 additions & 0 deletions
9
test/e2e/app-dir/server-source-maps/fixtures/default/app/ssr-throw/Thrower.js
This file contains 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' | ||
|
||
function throwError() { | ||
throw new Error('Boom') | ||
} | ||
|
||
export function Thrower() { | ||
throwError() | ||
} |
7 changes: 7 additions & 0 deletions
7
test/e2e/app-dir/server-source-maps/fixtures/default/app/ssr-throw/page.js
This file contains 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 { connection } from 'next/server' | ||
import { Thrower } from './Thrower' | ||
|
||
export default async function Page() { | ||
await connection() | ||
return <Thrower /> | ||
} |
9 changes: 9 additions & 0 deletions
9
test/e2e/app-dir/server-source-maps/fixtures/edge/app/layout.js
This file contains 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 const runtime = 'edge' | ||
|
||
export default function Root({ children }) { | ||
return ( | ||
<html> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} |
5 changes: 1 addition & 4 deletions
5
...ixtures/default/app/ssr-error-log/page.js → ...s/fixtures/edge/app/rsc-error-log/page.js
This file contains 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
8 changes: 8 additions & 0 deletions
8
test/e2e/app-dir/server-source-maps/fixtures/edge/app/rsc-throw/page.js
This file contains 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,8 @@ | ||
function throwError() { | ||
throw new Error('Boom') | ||
} | ||
|
||
export default function Page() { | ||
throwError() | ||
return null | ||
} |
10 changes: 10 additions & 0 deletions
10
test/e2e/app-dir/server-source-maps/fixtures/edge/app/ssr-throw/page.js
This file contains 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,10 @@ | ||
'use client' | ||
|
||
function throwError() { | ||
throw new Error('Boom') | ||
} | ||
|
||
export default function Page() { | ||
throwError() | ||
return null | ||
} |
10 changes: 10 additions & 0 deletions
10
test/e2e/app-dir/server-source-maps/fixtures/edge/next.config.js
This file contains 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,10 @@ | ||
/** | ||
* @type {import('next').NextConfig} | ||
*/ | ||
const nextConfig = { | ||
experimental: { | ||
serverSourceMaps: true, | ||
}, | ||
} | ||
|
||
module.exports = nextConfig |
99 changes: 99 additions & 0 deletions
99
test/e2e/app-dir/server-source-maps/server-source-maps-edge.test.ts
This file contains 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,99 @@ | ||
/* eslint-disable jest/no-standalone-expect */ | ||
import * as path from 'path' | ||
import { nextTestSetup } from 'e2e-utils' | ||
import stripAnsi from 'strip-ansi' | ||
import { retry } from 'next-test-utils' | ||
|
||
function normalizeCliOutput(output: string) { | ||
return stripAnsi(output) | ||
} | ||
|
||
describe('app-dir - server source maps edge runtime', () => { | ||
const { skipped, next, isNextDev, isTurbopack } = nextTestSetup({ | ||
files: path.join(__dirname, 'fixtures/edge'), | ||
// Deploy tests don't have access to runtime logs. | ||
// Manually verify that the runtime logs match. | ||
skipDeployment: true, | ||
}) | ||
|
||
if (skipped) return | ||
|
||
it('logged errors have a sourcemapped stack with a codeframe', async () => { | ||
const outputIndex = next.cliOutput.length | ||
await next.render('/rsc-error-log') | ||
|
||
if (isNextDev) { | ||
await retry(() => { | ||
expect(next.cliOutput.slice(outputIndex)).toContain('Error: Boom') | ||
}) | ||
expect(normalizeCliOutput(next.cliOutput.slice(outputIndex))).toContain( | ||
isTurbopack | ||
? // TODO(veil): Error stack should be printed | ||
'\n[Error: Boom]\n' | ||
: // TODO(veil): Error stack should be printed | ||
'\n[Error: Boom]\n' | ||
) | ||
} else { | ||
// TODO: Test `next build` with `--enable-source-maps`. | ||
} | ||
}) | ||
|
||
it('thrown SSR errors', async () => { | ||
const outputIndex = next.cliOutput.length | ||
await next.render('/ssr-throw') | ||
|
||
if (isNextDev) { | ||
await retry(() => { | ||
expect(next.cliOutput.slice(outputIndex)).toContain('Error: Boom') | ||
}) | ||
|
||
const cliOutput = stripAnsi(next.cliOutput.slice(outputIndex)) | ||
expect(cliOutput).toContain( | ||
isTurbopack | ||
? '\n ⨯ Error: Boom' + | ||
'\n at throwError (./app/ssr-throw/page.js:4:9)' + | ||
'\n at Page (./app/ssr-throw/page.js:8:3)' + | ||
'\ndigest: "' | ||
: '\n ⨯ Error: Boom' + | ||
'\n at throwError (./app/ssr-throw/page.js:6:11)' + | ||
'\n at Page (./app/ssr-throw/page.js:9:5)' + | ||
'\ndigest: "' | ||
) | ||
expect(cliOutput).toMatch(/digest: "\d+"/) | ||
} else { | ||
// TODO: Test `next build` with `--enable-source-maps`. | ||
} | ||
}) | ||
|
||
it('should log the correct values on app-render error', async () => { | ||
const outputIndex = next.cliOutput.length | ||
await next.fetch('/rsc-throw') | ||
|
||
if (isNextDev) { | ||
await retry(() => { | ||
expect(next.cliOutput.slice(outputIndex)).toMatch(/Error: Boom/) | ||
}) | ||
|
||
const cliOutput = stripAnsi(next.cliOutput.slice(outputIndex)) | ||
// TODO(veil): Hide Node.js internal stackframes | ||
expect(cliOutput).toContain( | ||
isTurbopack | ||
? '\n ⨯ Error: Boom' + | ||
'\n at throwError (./app/rsc-throw/page.js:2:9)' + | ||
'\n at Page (./app/rsc-throw/page.js:6:3)' + | ||
// TODO(veil): Hide Node.js internal stackframes | ||
'\n at AsyncLocalStorage.run (node:async_hooks:346:14)' + | ||
'\ndigest: "' | ||
: '\n ⨯ Error: Boom' + | ||
'\n at throwError (./app/rsc-throw/page.js:6:11)' + | ||
'\n at Page (./app/rsc-throw/page.js:9:5)' + | ||
// TODO(veil): Hide Node.js internal stackframes | ||
'\n at AsyncLocalStorage.run (node:async_hooks:346:14)' + | ||
'\ndigest: "' | ||
) | ||
expect(cliOutput).toMatch(/digest: "\d+"/) | ||
} else { | ||
// TODO: Test `next build` with `--enable-source-maps`. | ||
} | ||
}) | ||
}) |
Oops, something went wrong.