Unverified Commit 7d98e0b5 authored by Sebastian "Sebbie" Silbermann's avatar Sebastian "Sebbie" Silbermann Committed by GitHub

[test] Include error code in Redbox snapshot (#90497)

parent de03508d
...@@ -1558,6 +1558,7 @@ describe('ReactRefreshLogBox app', () => { ...@@ -1558,6 +1558,7 @@ describe('ReactRefreshLogBox app', () => {
if (isRspack) { if (isRspack) {
await expect({ browser, next }).toDisplayRedbox(` await expect({ browser, next }).toDisplayRedbox(`
{ {
"code": "E394",
"description": "module error", "description": "module error",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -1577,6 +1578,7 @@ describe('ReactRefreshLogBox app', () => { ...@@ -1577,6 +1578,7 @@ describe('ReactRefreshLogBox app', () => {
} else if (!isTurbopack) { } else if (!isTurbopack) {
await expect({ browser, next }).toDisplayRedbox(` await expect({ browser, next }).toDisplayRedbox(`
{ {
"code": "E394",
"description": "module error", "description": "module error",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
......
...@@ -139,6 +139,7 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -139,6 +139,7 @@ describe('Error overlay for hydration errors in App router', () => {
if (isTurbopack) { if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E394",
"componentStack": "... "componentStack": "...
<Next.js Internal Component> <Next.js Internal Component>
<Next.js Internal Component> <Next.js Internal Component>
...@@ -175,6 +176,7 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -175,6 +176,7 @@ describe('Error overlay for hydration errors in App router', () => {
} else { } else {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E394",
"componentStack": "... "componentStack": "...
<Next.js Internal Component> <Next.js Internal Component>
<Next.js Internal Component> <Next.js Internal Component>
...@@ -336,6 +338,7 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -336,6 +338,7 @@ describe('Error overlay for hydration errors in App router', () => {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
[ [
{ {
"code": "E394",
"componentStack": "... "componentStack": "...
<Next.js Internal Component> <Next.js Internal Component>
<Next.js Internal Component> <Next.js Internal Component>
...@@ -408,6 +411,7 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -408,6 +411,7 @@ describe('Error overlay for hydration errors in App router', () => {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E394",
"componentStack": "... "componentStack": "...
<Next.js Internal Component> <Next.js Internal Component>
<Next.js Internal Component> <Next.js Internal Component>
...@@ -503,6 +507,7 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -503,6 +507,7 @@ describe('Error overlay for hydration errors in App router', () => {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
[ [
{ {
"code": "E394",
"componentStack": "... "componentStack": "...
<Next.js Internal Component> <Next.js Internal Component>
<Next.js Internal Component> <Next.js Internal Component>
...@@ -560,6 +565,7 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -560,6 +565,7 @@ describe('Error overlay for hydration errors in App router', () => {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
[ [
{ {
"code": "E394",
"componentStack": "... "componentStack": "...
<Next.js Internal Component> <Next.js Internal Component>
<Next.js Internal Component> <Next.js Internal Component>
...@@ -618,6 +624,7 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -618,6 +624,7 @@ describe('Error overlay for hydration errors in App router', () => {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
[ [
{ {
"code": "E394",
"componentStack": "... "componentStack": "...
<Next.js Internal Component> <Next.js Internal Component>
<Next.js Internal Component> <Next.js Internal Component>
...@@ -675,6 +682,7 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -675,6 +682,7 @@ describe('Error overlay for hydration errors in App router', () => {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
[ [
{ {
"code": "E394",
"componentStack": "... "componentStack": "...
<Next.js Internal Component> <Next.js Internal Component>
<Next.js Internal Component> <Next.js Internal Component>
...@@ -711,6 +719,7 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -711,6 +719,7 @@ describe('Error overlay for hydration errors in App router', () => {
], ],
}, },
{ {
"code": "E394",
"description": "<p> cannot contain a nested <p>. "description": "<p> cannot contain a nested <p>.
See this log for the ancestor stack trace.", See this log for the ancestor stack trace.",
"environmentLabel": null, "environmentLabel": null,
...@@ -753,6 +762,7 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -753,6 +762,7 @@ describe('Error overlay for hydration errors in App router', () => {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
[ [
{ {
"code": "E394",
"description": "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.", "description": "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.",
"environmentLabel": null, "environmentLabel": null,
"label": "Console Error", "label": "Console Error",
...@@ -764,6 +774,7 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -764,6 +774,7 @@ describe('Error overlay for hydration errors in App router', () => {
], ],
}, },
{ {
"code": "E394",
"componentStack": "... "componentStack": "...
<Next.js Internal Component> <Next.js Internal Component>
<Next.js Internal Component> <Next.js Internal Component>
...@@ -799,6 +810,7 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -799,6 +810,7 @@ describe('Error overlay for hydration errors in App router', () => {
], ],
}, },
{ {
"code": "E394",
"description": "<html> cannot contain a nested <script>. "description": "<html> cannot contain a nested <script>.
See this log for the ancestor stack trace.", See this log for the ancestor stack trace.",
"environmentLabel": null, "environmentLabel": null,
...@@ -817,6 +829,7 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -817,6 +829,7 @@ describe('Error overlay for hydration errors in App router', () => {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
[ [
{ {
"code": "E394",
"description": "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.", "description": "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.",
"environmentLabel": null, "environmentLabel": null,
"label": "Console Error", "label": "Console Error",
...@@ -828,6 +841,7 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -828,6 +841,7 @@ describe('Error overlay for hydration errors in App router', () => {
], ],
}, },
{ {
"code": "E394",
"componentStack": "... "componentStack": "...
<Next.js Internal Component> <Next.js Internal Component>
<Next.js Internal Component> <Next.js Internal Component>
...@@ -861,6 +875,7 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -861,6 +875,7 @@ describe('Error overlay for hydration errors in App router', () => {
], ],
}, },
{ {
"code": "E394",
"description": "<html> cannot contain a nested <script>. "description": "<html> cannot contain a nested <script>.
See this log for the ancestor stack trace.", See this log for the ancestor stack trace.",
"environmentLabel": null, "environmentLabel": null,
......
...@@ -53,6 +53,7 @@ describe('Error overlay - RSC runtime errors', () => { ...@@ -53,6 +53,7 @@ describe('Error overlay - RSC runtime errors', () => {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E251",
"description": "\`cookies\` was called outside a request scope. Read more: https://nextjs.org/docs/messages/next-dynamic-api-wrong-context", "description": "\`cookies\` was called outside a request scope. Read more: https://nextjs.org/docs/messages/next-dynamic-api-wrong-context",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
......
...@@ -19,6 +19,7 @@ describe('ReactRefreshLogBox _app _document', () => { ...@@ -19,6 +19,7 @@ describe('ReactRefreshLogBox _app _document', () => {
const { browser, session } = sandbox const { browser, session } = sandbox
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "The default export is not a React Component in page: "/_app"", "description": "The default export is not a React Component in page: "/_app"",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -48,6 +49,7 @@ describe('ReactRefreshLogBox _app _document', () => { ...@@ -48,6 +49,7 @@ describe('ReactRefreshLogBox _app _document', () => {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "The default export is not a React Component in page: "/_document"", "description": "The default export is not a React Component in page: "/_document"",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
......
...@@ -159,6 +159,7 @@ describe('ReactRefreshLogBox', () => { ...@@ -159,6 +159,7 @@ describe('ReactRefreshLogBox', () => {
if (isTurbopack) { if (isTurbopack) {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "no", "description": "no",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -176,6 +177,7 @@ describe('ReactRefreshLogBox', () => { ...@@ -176,6 +177,7 @@ describe('ReactRefreshLogBox', () => {
} else if (isRspack) { } else if (isRspack) {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "no", "description": "no",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -202,6 +204,7 @@ describe('ReactRefreshLogBox', () => { ...@@ -202,6 +204,7 @@ describe('ReactRefreshLogBox', () => {
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "no", "description": "no",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -1106,6 +1109,7 @@ describe('ReactRefreshLogBox', () => { ...@@ -1106,6 +1109,7 @@ describe('ReactRefreshLogBox', () => {
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "{"a":1,"b":"x"}", "description": "{"a":1,"b":"x"}",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -1155,6 +1159,7 @@ describe('ReactRefreshLogBox', () => { ...@@ -1155,6 +1159,7 @@ describe('ReactRefreshLogBox', () => {
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "class Hello { "description": "class Hello {
}", }",
"environmentLabel": null, "environmentLabel": null,
...@@ -1202,6 +1207,7 @@ describe('ReactRefreshLogBox', () => { ...@@ -1202,6 +1207,7 @@ describe('ReactRefreshLogBox', () => {
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "string error", "description": "string error",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -1248,6 +1254,7 @@ describe('ReactRefreshLogBox', () => { ...@@ -1248,6 +1254,7 @@ describe('ReactRefreshLogBox', () => {
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "A null error was thrown, see here for more info: https://nextjs.org/docs/messages/threw-undefined", "description": "A null error was thrown, see here for more info: https://nextjs.org/docs/messages/threw-undefined",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -1403,6 +1410,7 @@ describe('ReactRefreshLogBox', () => { ...@@ -1403,6 +1410,7 @@ describe('ReactRefreshLogBox', () => {
if (isTurbopack) { if (isTurbopack) {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "anonymous error!", "description": "anonymous error!",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -1419,6 +1427,7 @@ describe('ReactRefreshLogBox', () => { ...@@ -1419,6 +1427,7 @@ describe('ReactRefreshLogBox', () => {
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "anonymous error!", "description": "anonymous error!",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -1460,6 +1469,7 @@ describe('ReactRefreshLogBox', () => { ...@@ -1460,6 +1469,7 @@ describe('ReactRefreshLogBox', () => {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "Invalid URL", "description": "Invalid URL",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime TypeError", "label": "Runtime TypeError",
......
...@@ -284,6 +284,7 @@ describe('ReactRefreshRegression', () => { ...@@ -284,6 +284,7 @@ describe('ReactRefreshRegression', () => {
if (isTurbopack) { if (isTurbopack) {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "boom", "description": "boom",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -298,6 +299,7 @@ describe('ReactRefreshRegression', () => { ...@@ -298,6 +299,7 @@ describe('ReactRefreshRegression', () => {
} else if (isRspack) { } else if (isRspack) {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "boom", "description": "boom",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -312,6 +314,7 @@ describe('ReactRefreshRegression', () => { ...@@ -312,6 +314,7 @@ describe('ReactRefreshRegression', () => {
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "boom", "description": "boom",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
......
...@@ -12,6 +12,7 @@ describe('app-dir - capture-console-error-owner-stack', () => { ...@@ -12,6 +12,7 @@ describe('app-dir - capture-console-error-owner-stack', () => {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E394",
"description": "trigger an console <error>", "description": "trigger an console <error>",
"environmentLabel": null, "environmentLabel": null,
"label": "Console Error", "label": "Console Error",
...@@ -32,6 +33,7 @@ describe('app-dir - capture-console-error-owner-stack', () => { ...@@ -32,6 +33,7 @@ describe('app-dir - capture-console-error-owner-stack', () => {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E394",
"description": "trigger an console.error in render", "description": "trigger an console.error in render",
"environmentLabel": null, "environmentLabel": null,
"label": "Console Error", "label": "Console Error",
...@@ -50,6 +52,7 @@ describe('app-dir - capture-console-error-owner-stack', () => { ...@@ -50,6 +52,7 @@ describe('app-dir - capture-console-error-owner-stack', () => {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E394",
"description": "trigger an console.error in render", "description": "trigger an console.error in render",
"environmentLabel": null, "environmentLabel": null,
"label": "Console Error", "label": "Console Error",
...@@ -68,6 +71,7 @@ describe('app-dir - capture-console-error-owner-stack', () => { ...@@ -68,6 +71,7 @@ describe('app-dir - capture-console-error-owner-stack', () => {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E394",
"description": "ssr console error:client", "description": "ssr console error:client",
"environmentLabel": null, "environmentLabel": null,
"label": "Console Error", "label": "Console Error",
......
...@@ -13,6 +13,7 @@ describe('app dir - dynamic error trace', () => { ...@@ -13,6 +13,7 @@ describe('app dir - dynamic error trace', () => {
// TODO(veil): Where is the stackframe for app/page.js? // TODO(veil): Where is the stackframe for app/page.js?
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E828",
"description": "Route / with \`dynamic = "error"\` couldn't be rendered statically because it used \`headers()\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering", "description": "Route / with \`dynamic = "error"\` couldn't be rendered statically because it used \`headers()\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Runtime Error", "label": "Runtime Error",
......
...@@ -17,6 +17,7 @@ describe('app-dir - async-client-component', () => { ...@@ -17,6 +17,7 @@ describe('app-dir - async-client-component', () => {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
[ [
{ {
"code": "E394",
"description": "<Page> is an async Client Component. Only Server Components can be async at the moment. This error is often caused by accidentally adding \`'use client'\` to a module that was originally written for the server.", "description": "<Page> is an async Client Component. Only Server Components can be async at the moment. This error is often caused by accidentally adding \`'use client'\` to a module that was originally written for the server.",
"environmentLabel": null, "environmentLabel": null,
"label": "Console Error", "label": "Console Error",
...@@ -24,6 +25,7 @@ describe('app-dir - async-client-component', () => { ...@@ -24,6 +25,7 @@ describe('app-dir - async-client-component', () => {
"stack": [], "stack": [],
}, },
{ {
"code": "E394",
"description": "A component was suspended by an uncached promise. Creating promises inside a Client Component or hook is not yet supported, except via a Suspense-compatible library or framework.", "description": "A component was suspended by an uncached promise. Creating promises inside a Client Component or hook is not yet supported, except via a Suspense-compatible library or framework.",
"environmentLabel": null, "environmentLabel": null,
"label": "Console Error", "label": "Console Error",
......
...@@ -12,6 +12,7 @@ describe('hydration-error-count', () => { ...@@ -12,6 +12,7 @@ describe('hydration-error-count', () => {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
[ [
{ {
"code": "E394",
"componentStack": "... "componentStack": "...
<Next.js Internal Component> <Next.js Internal Component>
<Next.js Internal Component> <Next.js Internal Component>
...@@ -61,6 +62,7 @@ describe('hydration-error-count', () => { ...@@ -61,6 +62,7 @@ describe('hydration-error-count', () => {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
[ [
{ {
"code": "E394",
"componentStack": "... "componentStack": "...
<Next.js Internal Component> <Next.js Internal Component>
<Next.js Internal Component> <Next.js Internal Component>
...@@ -192,6 +194,7 @@ describe('hydration-error-count', () => { ...@@ -192,6 +194,7 @@ describe('hydration-error-count', () => {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
[ [
{ {
"code": "E394",
"componentStack": "... "componentStack": "...
<Next.js Internal Component> <Next.js Internal Component>
<Next.js Internal Component> <Next.js Internal Component>
...@@ -262,6 +265,7 @@ describe('hydration-error-count', () => { ...@@ -262,6 +265,7 @@ describe('hydration-error-count', () => {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
[ [
{ {
"code": "E394",
"componentStack": "... "componentStack": "...
<Next.js Internal Component> <Next.js Internal Component>
<Next.js Internal Component> <Next.js Internal Component>
...@@ -337,6 +341,7 @@ describe('hydration-error-count', () => { ...@@ -337,6 +341,7 @@ describe('hydration-error-count', () => {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
[ [
{ {
"code": "E394",
"componentStack": "... "componentStack": "...
<Next.js Internal Component> <Next.js Internal Component>
<Next.js Internal Component> <Next.js Internal Component>
......
...@@ -32,6 +32,7 @@ describe('app-dir - missing required html tags', () => { ...@@ -32,6 +32,7 @@ describe('app-dir - missing required html tags', () => {
await waitForRedbox(browser) await waitForRedbox(browser)
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "Missing <html> and <body> tags in the root layout. "description": "Missing <html> and <body> tags in the root layout.
Read more at https://nextjs.org/docs/messages/missing-root-layout-tags", Read more at https://nextjs.org/docs/messages/missing-root-layout-tags",
"environmentLabel": null, "environmentLabel": null,
...@@ -57,6 +58,7 @@ describe('app-dir - missing required html tags', () => { ...@@ -57,6 +58,7 @@ describe('app-dir - missing required html tags', () => {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "Missing <html> and <body> tags in the root layout. "description": "Missing <html> and <body> tags in the root layout.
Read more at https://nextjs.org/docs/messages/missing-root-layout-tags", Read more at https://nextjs.org/docs/messages/missing-root-layout-tags",
"environmentLabel": null, "environmentLabel": null,
...@@ -77,15 +79,16 @@ describe('app-dir - missing required html tags', () => { ...@@ -77,15 +79,16 @@ describe('app-dir - missing required html tags', () => {
await retry(() => await retry(() =>
expect(browser).toDisplayRedbox(` expect(browser).toDisplayRedbox(`
{ {
"description": "Missing <html> tags in the root layout. "code": "E394",
Read more at https://nextjs.org/docs/messages/missing-root-layout-tags", "description": "Missing <html> tags in the root layout.
"environmentLabel": null, Read more at https://nextjs.org/docs/messages/missing-root-layout-tags",
"label": "Runtime Error", "environmentLabel": null,
"source": null, "label": "Runtime Error",
"stack": [], "source": null,
} "stack": [],
`) }
`)
) )
reloaded = false reloaded = false
......
...@@ -160,6 +160,7 @@ describe('app-dir - owner-stack', () => { ...@@ -160,6 +160,7 @@ describe('app-dir - owner-stack', () => {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E394",
"description": "string in rejected promise", "description": "string in rejected promise",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
......
...@@ -10,6 +10,7 @@ describe('serialize-circular-error', () => { ...@@ -10,6 +10,7 @@ describe('serialize-circular-error', () => {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "An error occurred but serializing the error message failed.", "description": "An error occurred but serializing the error message failed.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Runtime Error", "label": "Runtime Error",
...@@ -29,6 +30,7 @@ describe('serialize-circular-error', () => { ...@@ -29,6 +30,7 @@ describe('serialize-circular-error', () => {
// TODO: Format arbitrary messages in Redbox // TODO: Format arbitrary messages in Redbox
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "[object Object]", "description": "[object Object]",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
......
...@@ -11,6 +11,7 @@ describe('server-navigation-error', () => { ...@@ -11,6 +11,7 @@ describe('server-navigation-error', () => {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "Next.js navigation API is not allowed to be used in Pages Router.", "description": "Next.js navigation API is not allowed to be used in Pages Router.",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -29,6 +30,7 @@ describe('server-navigation-error', () => { ...@@ -29,6 +30,7 @@ describe('server-navigation-error', () => {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "Next.js navigation API is not allowed to be used in Pages Router.", "description": "Next.js navigation API is not allowed to be used in Pages Router.",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -51,6 +53,7 @@ describe('server-navigation-error', () => { ...@@ -51,6 +53,7 @@ describe('server-navigation-error', () => {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "Next.js navigation API is not allowed to be used in Middleware.", "description": "Next.js navigation API is not allowed to be used in Middleware.",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -69,6 +72,7 @@ describe('server-navigation-error', () => { ...@@ -69,6 +72,7 @@ describe('server-navigation-error', () => {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "Next.js navigation API is not allowed to be used in Middleware.", "description": "Next.js navigation API is not allowed to be used in Middleware.",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
......
...@@ -12,6 +12,7 @@ describe('ssr-only-error', () => { ...@@ -12,6 +12,7 @@ describe('ssr-only-error', () => {
// TODO(veil): Missing Owner Stack (NDX-905) // TODO(veil): Missing Owner Stack (NDX-905)
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E394",
"description": "SSR only error", "description": "SSR only error",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
......
...@@ -278,6 +278,7 @@ describe('GS(S)P Server-Side Change Reloading', () => { ...@@ -278,6 +278,7 @@ describe('GS(S)P Server-Side Change Reloading', () => {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "Additional keys were returned from \`getStaticProps\`. Properties intended for your component must be nested under the \`props\` key, e.g.: "description": "Additional keys were returned from \`getStaticProps\`. Properties intended for your component must be nested under the \`props\` key, e.g.:
return { props: { title: 'My Title', content: '...' } } return { props: { title: 'My Title', content: '...' } }
...@@ -319,6 +320,7 @@ describe('GS(S)P Server-Side Change Reloading', () => { ...@@ -319,6 +320,7 @@ describe('GS(S)P Server-Side Change Reloading', () => {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "custom oops", "description": "custom oops",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
......
...@@ -58,6 +58,7 @@ describe('middleware - development errors', () => { ...@@ -58,6 +58,7 @@ describe('middleware - development errors', () => {
if (isTurbopack) { if (isTurbopack) {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "boom", "description": "boom",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -72,6 +73,7 @@ describe('middleware - development errors', () => { ...@@ -72,6 +73,7 @@ describe('middleware - development errors', () => {
} else if (isRspack) { } else if (isRspack) {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "boom", "description": "boom",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -86,6 +88,7 @@ describe('middleware - development errors', () => { ...@@ -86,6 +88,7 @@ describe('middleware - development errors', () => {
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "boom", "description": "boom",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -224,6 +227,7 @@ describe('middleware - development errors', () => { ...@@ -224,6 +227,7 @@ describe('middleware - development errors', () => {
if (isTurbopack) { if (isTurbopack) {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "test is not defined", "description": "test is not defined",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime ReferenceError", "label": "Runtime ReferenceError",
...@@ -240,6 +244,7 @@ describe('middleware - development errors', () => { ...@@ -240,6 +244,7 @@ describe('middleware - development errors', () => {
} else if (isRspack) { } else if (isRspack) {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "test is not defined", "description": "test is not defined",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime ReferenceError", "label": "Runtime ReferenceError",
...@@ -255,6 +260,7 @@ describe('middleware - development errors', () => { ...@@ -255,6 +260,7 @@ describe('middleware - development errors', () => {
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "test is not defined", "description": "test is not defined",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime ReferenceError", "label": "Runtime ReferenceError",
...@@ -328,6 +334,7 @@ describe('middleware - development errors', () => { ...@@ -328,6 +334,7 @@ describe('middleware - development errors', () => {
if (isTurbopack) { if (isTurbopack) {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "booooom!", "description": "booooom!",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -342,6 +349,7 @@ describe('middleware - development errors', () => { ...@@ -342,6 +349,7 @@ describe('middleware - development errors', () => {
} else if (isRspack) { } else if (isRspack) {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "booooom!", "description": "booooom!",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -365,6 +373,7 @@ describe('middleware - development errors', () => { ...@@ -365,6 +373,7 @@ describe('middleware - development errors', () => {
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "booooom!", "description": "booooom!",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
......
...@@ -30,6 +30,7 @@ describe('Client Navigation', () => { ...@@ -30,6 +30,7 @@ describe('Client Navigation', () => {
await browser.elementByCss('#empty-props').click() await browser.elementByCss('#empty-props').click()
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E1025",
"description": ""EmptyInitialPropsPage.getInitialProps()" should resolve to an object. But found "null" instead.", "description": ""EmptyInitialPropsPage.getInitialProps()" should resolve to an object. But found "null" instead.",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
......
...@@ -130,6 +130,7 @@ describe('Client Navigation rendering', () => { ...@@ -130,6 +130,7 @@ describe('Client Navigation rendering', () => {
if (isReact18 && isTurbopack) { if (isReact18 && isTurbopack) {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "Circular structure in "getInitialProps" result of page "/circular-json-error". https://nextjs.org/docs/messages/circular-structure", "description": "Circular structure in "getInitialProps" result of page "/circular-json-error". https://nextjs.org/docs/messages/circular-structure",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -142,6 +143,7 @@ describe('Client Navigation rendering', () => { ...@@ -142,6 +143,7 @@ describe('Client Navigation rendering', () => {
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "Circular structure in "getInitialProps" result of page "/circular-json-error". https://nextjs.org/docs/messages/circular-structure", "description": "Circular structure in "getInitialProps" result of page "/circular-json-error". https://nextjs.org/docs/messages/circular-structure",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -160,6 +162,7 @@ describe('Client Navigation rendering', () => { ...@@ -160,6 +162,7 @@ describe('Client Navigation rendering', () => {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": ""InstanceInitialPropsPage.getInitialProps()" is defined as an instance method - visit https://nextjs.org/docs/messages/get-initial-props-as-an-instance-method for more information.", "description": ""InstanceInitialPropsPage.getInitialProps()" is defined as an instance method - visit https://nextjs.org/docs/messages/get-initial-props-as-an-instance-method for more information.",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -174,6 +177,7 @@ describe('Client Navigation rendering', () => { ...@@ -174,6 +177,7 @@ describe('Client Navigation rendering', () => {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": ""EmptyInitialPropsPage.getInitialProps()" should resolve to an object. But found "null" instead.", "description": ""EmptyInitialPropsPage.getInitialProps()" should resolve to an object. But found "null" instead.",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -217,6 +221,7 @@ describe('Client Navigation rendering', () => { ...@@ -217,6 +221,7 @@ describe('Client Navigation rendering', () => {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "The default export is not a React Component in page: "/no-default-export"", "description": "The default export is not a React Component in page: "/no-default-export"",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -232,6 +237,7 @@ describe('Client Navigation rendering', () => { ...@@ -232,6 +237,7 @@ describe('Client Navigation rendering', () => {
if (isTurbopack) { if (isTurbopack) {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "This is an expected error", "description": "This is an expected error",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -246,6 +252,7 @@ describe('Client Navigation rendering', () => { ...@@ -246,6 +252,7 @@ describe('Client Navigation rendering', () => {
} else if (isRspack) { } else if (isRspack) {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "This is an expected error", "description": "This is an expected error",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -260,6 +267,7 @@ describe('Client Navigation rendering', () => { ...@@ -260,6 +267,7 @@ describe('Client Navigation rendering', () => {
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "This is an expected error", "description": "This is an expected error",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -283,6 +291,7 @@ describe('Client Navigation rendering', () => { ...@@ -283,6 +291,7 @@ describe('Client Navigation rendering', () => {
if (isTurbopack) { if (isTurbopack) {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "aa is not defined", "description": "aa is not defined",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime ReferenceError", "label": "Runtime ReferenceError",
...@@ -298,6 +307,7 @@ describe('Client Navigation rendering', () => { ...@@ -298,6 +307,7 @@ describe('Client Navigation rendering', () => {
} else if (isRspack) { } else if (isRspack) {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "aa is not defined", "description": "aa is not defined",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime ReferenceError", "label": "Runtime ReferenceError",
...@@ -321,6 +331,7 @@ describe('Client Navigation rendering', () => { ...@@ -321,6 +331,7 @@ describe('Client Navigation rendering', () => {
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "aa is not defined", "description": "aa is not defined",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime ReferenceError", "label": "Runtime ReferenceError",
...@@ -447,6 +458,7 @@ describe('Client Navigation rendering', () => { ...@@ -447,6 +458,7 @@ describe('Client Navigation rendering', () => {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "An undefined error was thrown, see here for more info: https://nextjs.org/docs/messages/threw-undefined", "description": "An undefined error was thrown, see here for more info: https://nextjs.org/docs/messages/threw-undefined",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
......
...@@ -16,6 +16,7 @@ describe('app-root-param-getters - cache - at runtime', () => { ...@@ -16,6 +16,7 @@ describe('app-root-param-getters - cache - at runtime', () => {
const browser = await next.browser('/en/us/use-cache') const browser = await next.browser('/en/us/use-cache')
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E1012",
"description": "Route /[lang]/[locale]/use-cache used \`import('next/root-params').lang()\` inside \`"use cache"\` or \`unstable_cache\`. Support for this API inside cache scopes is planned for a future version of Next.js.", "description": "Route /[lang]/[locale]/use-cache used \`import('next/root-params').lang()\` inside \`"use cache"\` or \`unstable_cache\`. Support for this API inside cache scopes is planned for a future version of Next.js.",
"environmentLabel": "Cache", "environmentLabel": "Cache",
"label": "Runtime Error", "label": "Runtime Error",
...@@ -33,6 +34,7 @@ describe('app-root-param-getters - cache - at runtime', () => { ...@@ -33,6 +34,7 @@ describe('app-root-param-getters - cache - at runtime', () => {
const browser = await next.browser('/en/us/unstable_cache') const browser = await next.browser('/en/us/unstable_cache')
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E1012",
"description": "Route /[lang]/[locale]/unstable_cache used \`import('next/root-params').lang()\` inside \`"use cache"\` or \`unstable_cache\`. Support for this API inside cache scopes is planned for a future version of Next.js.", "description": "Route /[lang]/[locale]/unstable_cache used \`import('next/root-params').lang()\` inside \`"use cache"\` or \`unstable_cache\`. Support for this API inside cache scopes is planned for a future version of Next.js.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Runtime Error", "label": "Runtime Error",
......
...@@ -178,6 +178,7 @@ describe('dynamic-data with dynamic = "error"', () => { ...@@ -178,6 +178,7 @@ describe('dynamic-data with dynamic = "error"', () => {
try { try {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E849",
"description": "Route /cookies with \`dynamic = "error"\` couldn't be rendered statically because it used \`cookies()\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering", "description": "Route /cookies with \`dynamic = "error"\` couldn't be rendered statically because it used \`cookies()\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Runtime Error", "label": "Runtime Error",
...@@ -197,6 +198,7 @@ describe('dynamic-data with dynamic = "error"', () => { ...@@ -197,6 +198,7 @@ describe('dynamic-data with dynamic = "error"', () => {
try { try {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E847",
"description": "Route /connection with \`dynamic = "error"\` couldn't be rendered statically because it used \`connection()\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering", "description": "Route /connection with \`dynamic = "error"\` couldn't be rendered statically because it used \`connection()\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Runtime Error", "label": "Runtime Error",
...@@ -216,6 +218,7 @@ describe('dynamic-data with dynamic = "error"', () => { ...@@ -216,6 +218,7 @@ describe('dynamic-data with dynamic = "error"', () => {
try { try {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E828",
"description": "Route /headers with \`dynamic = "error"\` couldn't be rendered statically because it used \`headers()\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering", "description": "Route /headers with \`dynamic = "error"\` couldn't be rendered statically because it used \`headers()\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Runtime Error", "label": "Runtime Error",
...@@ -235,6 +238,7 @@ describe('dynamic-data with dynamic = "error"', () => { ...@@ -235,6 +238,7 @@ describe('dynamic-data with dynamic = "error"', () => {
try { try {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E543",
"description": "Route /search with \`dynamic = "error"\` couldn't be rendered statically because it used \`searchParams.then\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering", "description": "Route /search with \`dynamic = "error"\` couldn't be rendered statically because it used \`searchParams.then\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Runtime Error", "label": "Runtime Error",
...@@ -307,6 +311,7 @@ describe('dynamic-data inside cache scope', () => { ...@@ -307,6 +311,7 @@ describe('dynamic-data inside cache scope', () => {
try { try {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E846",
"description": "Route /cookies used \`cookies()\` inside a function cached with \`unstable_cache()\`. Accessing Dynamic data sources inside a cache scope is not supported. If you need this data inside a cached function use \`cookies()\` outside of the cached function and pass the required dynamic data in as an argument. See more info here: https://nextjs.org/docs/app/api-reference/functions/unstable_cache", "description": "Route /cookies used \`cookies()\` inside a function cached with \`unstable_cache()\`. Accessing Dynamic data sources inside a cache scope is not supported. If you need this data inside a cached function use \`cookies()\` outside of the cached function and pass the required dynamic data in as an argument. See more info here: https://nextjs.org/docs/app/api-reference/functions/unstable_cache",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Runtime Error", "label": "Runtime Error",
...@@ -327,6 +332,7 @@ describe('dynamic-data inside cache scope', () => { ...@@ -327,6 +332,7 @@ describe('dynamic-data inside cache scope', () => {
try { try {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E840",
"description": "Route /connection used \`connection()\` inside a function cached with \`unstable_cache()\`. The \`connection()\` function is used to indicate the subsequent code must only run when there is an actual Request, but caches must be able to be produced before a Request so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/app/api-reference/functions/unstable_cache", "description": "Route /connection used \`connection()\` inside a function cached with \`unstable_cache()\`. The \`connection()\` function is used to indicate the subsequent code must only run when there is an actual Request, but caches must be able to be produced before a Request so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/app/api-reference/functions/unstable_cache",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Runtime Error", "label": "Runtime Error",
...@@ -347,6 +353,7 @@ describe('dynamic-data inside cache scope', () => { ...@@ -347,6 +353,7 @@ describe('dynamic-data inside cache scope', () => {
try { try {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E838",
"description": "Route /headers used \`headers()\` inside a function cached with \`unstable_cache()\`. Accessing Dynamic data sources inside a cache scope is not supported. If you need this data inside a cached function use \`headers()\` outside of the cached function and pass the required dynamic data in as an argument. See more info here: https://nextjs.org/docs/app/api-reference/functions/unstable_cache", "description": "Route /headers used \`headers()\` inside a function cached with \`unstable_cache()\`. Accessing Dynamic data sources inside a cache scope is not supported. If you need this data inside a cached function use \`headers()\` outside of the cached function and pass the required dynamic data in as an argument. See more info here: https://nextjs.org/docs/app/api-reference/functions/unstable_cache",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Runtime Error", "label": "Runtime Error",
......
...@@ -20,6 +20,7 @@ describe('dynamic-href', () => { ...@@ -20,6 +20,7 @@ describe('dynamic-href', () => {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E267",
"description": "Dynamic href \`/object/[slug]\` found in <Link> while using the \`/app\` router, this is not supported. Read more: https://nextjs.org/docs/messages/app-dir-dynamic-href", "description": "Dynamic href \`/object/[slug]\` found in <Link> while using the \`/app\` router, this is not supported. Read more: https://nextjs.org/docs/messages/app-dir-dynamic-href",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -56,6 +57,7 @@ describe('dynamic-href', () => { ...@@ -56,6 +57,7 @@ describe('dynamic-href', () => {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E267",
"description": "Dynamic href \`/object/[slug]\` found in <Link> while using the \`/app\` router, this is not supported. Read more: https://nextjs.org/docs/messages/app-dir-dynamic-href", "description": "Dynamic href \`/object/[slug]\` found in <Link> while using the \`/app\` router, this is not supported. Read more: https://nextjs.org/docs/messages/app-dir-dynamic-href",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
......
...@@ -20,6 +20,7 @@ describe('app dir - not found with default 404 page', () => { ...@@ -20,6 +20,7 @@ describe('app dir - not found with default 404 page', () => {
// TODO: Either allow or include original stack // TODO: Either allow or include original stack
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E192",
"description": "notFound() is not allowed to use in root layout", "description": "notFound() is not allowed to use in root layout",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -51,6 +52,7 @@ describe('app dir - not found with default 404 page', () => { ...@@ -51,6 +52,7 @@ describe('app dir - not found with default 404 page', () => {
// TODO: Either allow or include original stack // TODO: Either allow or include original stack
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E192",
"description": "notFound() is not allowed to use in root layout", "description": "notFound() is not allowed to use in root layout",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
......
...@@ -14,6 +14,7 @@ describe('Undefined default export', () => { ...@@ -14,6 +14,7 @@ describe('Undefined default export', () => {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "The default export is not a React Component in "/specific-path/1/page"", "description": "The default export is not a React Component in "/specific-path/1/page"",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -28,6 +29,7 @@ describe('Undefined default export', () => { ...@@ -28,6 +29,7 @@ describe('Undefined default export', () => {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "The default export is not a React Component in "/specific-path/2/layout"", "description": "The default export is not a React Component in "/specific-path/2/layout"",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -42,6 +44,7 @@ describe('Undefined default export', () => { ...@@ -42,6 +44,7 @@ describe('Undefined default export', () => {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "The default export is not a React Component in "/will-not-found/not-found"", "description": "The default export is not a React Component in "/will-not-found/not-found"",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
......
...@@ -136,6 +136,7 @@ describe('use-cache-search-params', () => { ...@@ -136,6 +136,7 @@ describe('use-cache-search-params', () => {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "Route /search-params-used-generate-metadata used \`searchParams\` inside "use cache". Accessing dynamic request data inside a cache scope is not supported. If you need some search params inside a cached function await \`searchParams\` outside of the cached function and pass only the required search params as arguments to the cached function. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache", "description": "Route /search-params-used-generate-metadata used \`searchParams\` inside "use cache". Accessing dynamic request data inside a cache scope is not supported. If you need some search params inside a cached function await \`searchParams\` outside of the cached function and pass only the required search params as arguments to the cached function. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -156,6 +157,7 @@ describe('use-cache-search-params', () => { ...@@ -156,6 +157,7 @@ describe('use-cache-search-params', () => {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "Route /search-params-used-generate-viewport used \`searchParams\` inside "use cache". Accessing dynamic request data inside a cache scope is not supported. If you need some search params inside a cached function await \`searchParams\` outside of the cached function and pass only the required search params as arguments to the cached function. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache", "description": "Route /search-params-used-generate-viewport used \`searchParams\` inside "use cache". Accessing dynamic request data inside a cache scope is not supported. If you need some search params inside a cached function await \`searchParams\` outside of the cached function and pass only the required search params as arguments to the cached function. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
......
...@@ -47,6 +47,7 @@ describe('fetch failures have good stack traces in edge runtime', () => { ...@@ -47,6 +47,7 @@ describe('fetch failures have good stack traces in edge runtime', () => {
// eslint-disable-next-line jest/no-standalone-expect // eslint-disable-next-line jest/no-standalone-expect
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "fetch failed", "description": "fetch failed",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime TypeError", "label": "Runtime TypeError",
......
...@@ -30,6 +30,7 @@ describe('Validations for <Link legacyBehavior>', () => { ...@@ -30,6 +30,7 @@ describe('Validations for <Link legacyBehavior>', () => {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
[ [
{ {
"code": "E394",
"description": "Using a Server Component as a direct child of \`<Link legacyBehavior>\` is not supported. If you need legacyBehavior, wrap your Server Component in a Client Component that renders the Link's \`<a>\` tag.", "description": "Using a Server Component as a direct child of \`<Link legacyBehavior>\` is not supported. If you need legacyBehavior, wrap your Server Component in a Client Component that renders the Link's \`<a>\` tag.",
"environmentLabel": "Prerender", "environmentLabel": "Prerender",
"label": "Console Error", "label": "Console Error",
...@@ -41,6 +42,7 @@ describe('Validations for <Link legacyBehavior>', () => { ...@@ -41,6 +42,7 @@ describe('Validations for <Link legacyBehavior>', () => {
], ],
}, },
{ {
"code": "E394",
"description": "\`legacyBehavior\` is deprecated and will be removed in a future release. A codemod is available to upgrade your components: "description": "\`legacyBehavior\` is deprecated and will be removed in a future release. A codemod is available to upgrade your components:
npx @next/codemod@latest new-link . npx @next/codemod@latest new-link .
...@@ -74,6 +76,7 @@ describe('Validations for <Link legacyBehavior>', () => { ...@@ -74,6 +76,7 @@ describe('Validations for <Link legacyBehavior>', () => {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
[ [
{ {
"code": "E394",
"description": "Using a Server Component as a direct child of \`<Link legacyBehavior>\` is not supported. If you need legacyBehavior, wrap your Server Component in a Client Component that renders the Link's \`<a>\` tag.", "description": "Using a Server Component as a direct child of \`<Link legacyBehavior>\` is not supported. If you need legacyBehavior, wrap your Server Component in a Client Component that renders the Link's \`<a>\` tag.",
"environmentLabel": "Prerender", "environmentLabel": "Prerender",
"label": "Console Error", "label": "Console Error",
...@@ -85,6 +88,7 @@ describe('Validations for <Link legacyBehavior>', () => { ...@@ -85,6 +88,7 @@ describe('Validations for <Link legacyBehavior>', () => {
], ],
}, },
{ {
"code": "E863",
"description": "\`<Link legacyBehavior>\` received a direct child that is either a Server Component, or JSX that was loaded with React.lazy(). This is not supported. Either remove legacyBehavior, or make the direct child a Client Component that renders the Link's \`<a>\` tag.", "description": "\`<Link legacyBehavior>\` received a direct child that is either a Server Component, or JSX that was loaded with React.lazy(). This is not supported. Either remove legacyBehavior, or make the direct child a Client Component that renders the Link's \`<a>\` tag.",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -145,6 +149,7 @@ describe('Validations for <Link legacyBehavior>', () => { ...@@ -145,6 +149,7 @@ describe('Validations for <Link legacyBehavior>', () => {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
[ [
{ {
"code": "E394",
"description": "Using a Lazy Component as a direct child of \`<Link legacyBehavior>\` from a Server Component is not supported. If you need legacyBehavior, wrap your Lazy Component in a Client Component that renders the Link's \`<a>\` tag.", "description": "Using a Lazy Component as a direct child of \`<Link legacyBehavior>\` from a Server Component is not supported. If you need legacyBehavior, wrap your Lazy Component in a Client Component that renders the Link's \`<a>\` tag.",
"environmentLabel": "Prerender", "environmentLabel": "Prerender",
"label": "Console Error", "label": "Console Error",
...@@ -156,6 +161,7 @@ describe('Validations for <Link legacyBehavior>', () => { ...@@ -156,6 +161,7 @@ describe('Validations for <Link legacyBehavior>', () => {
], ],
}, },
{ {
"code": "E863",
"description": "\`<Link legacyBehavior>\` received a direct child that is either a Server Component, or JSX that was loaded with React.lazy(). This is not supported. Either remove legacyBehavior, or make the direct child a Client Component that renders the Link's \`<a>\` tag.", "description": "\`<Link legacyBehavior>\` received a direct child that is either a Server Component, or JSX that was loaded with React.lazy(). This is not supported. Either remove legacyBehavior, or make the direct child a Client Component that renders the Link's \`<a>\` tag.",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -201,18 +207,19 @@ describe('Validations for <Link legacyBehavior>', () => { ...@@ -201,18 +207,19 @@ describe('Validations for <Link legacyBehavior>', () => {
if (isNextDev) { if (isNextDev) {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"description": "\`<Link legacyBehavior>\` received a direct child that is either a Server Component, or JSX that was loaded with React.lazy(). This is not supported. Either remove legacyBehavior, or make the direct child a Client Component that renders the Link's \`<a>\` tag.", "code": "E863",
"environmentLabel": null, "description": "\`<Link legacyBehavior>\` received a direct child that is either a Server Component, or JSX that was loaded with React.lazy(). This is not supported. Either remove legacyBehavior, or make the direct child a Client Component that renders the Link's \`<a>\` tag.",
"label": "Runtime Error", "environmentLabel": null,
"source": "app/validations/rsc-that-renders-client/client-link.tsx (7:10) @ ClientLink "label": "Runtime Error",
> 7 | return <Link legacyBehavior passHref {...props} /> "source": "app/validations/rsc-that-renders-client/client-link.tsx (7:10) @ ClientLink
| ^", > 7 | return <Link legacyBehavior passHref {...props} />
"stack": [ | ^",
"ClientLink app/validations/rsc-that-renders-client/client-link.tsx (7:10)", "stack": [
"Page app/validations/rsc-that-renders-client/asynchronous/page.tsx (7:7)", "ClientLink app/validations/rsc-that-renders-client/client-link.tsx (7:10)",
], "Page app/validations/rsc-that-renders-client/asynchronous/page.tsx (7:7)",
} ],
}
`) `)
} else { } else {
const output = getContentBetween({ const output = getContentBetween({
...@@ -261,6 +268,7 @@ describe('Validations for <Link legacyBehavior>', () => { ...@@ -261,6 +268,7 @@ describe('Validations for <Link legacyBehavior>', () => {
if (isNextDev) { if (isNextDev) {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E320",
"description": "No children were passed to <Link> with \`href\` of \`/about\` but one child is required https://nextjs.org/docs/messages/link-no-children", "description": "No children were passed to <Link> with \`href\` of \`/about\` but one child is required https://nextjs.org/docs/messages/link-no-children",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
...@@ -292,6 +300,7 @@ describe('Validations for <Link legacyBehavior>', () => { ...@@ -292,6 +300,7 @@ describe('Validations for <Link legacyBehavior>', () => {
if (isNextDev) { if (isNextDev) {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E266",
"description": "Multiple children were passed to <Link> with \`href\` of \`/about\` but only one child is supported https://nextjs.org/docs/messages/link-multiple-children "description": "Multiple children were passed to <Link> with \`href\` of \`/about\` but only one child is supported https://nextjs.org/docs/messages/link-multiple-children
Open your browser's console to view the Component stack trace.", Open your browser's console to view the Component stack trace.",
"environmentLabel": null, "environmentLabel": null,
...@@ -332,6 +341,7 @@ describe('Validations for <Link legacyBehavior>', () => { ...@@ -332,6 +341,7 @@ describe('Validations for <Link legacyBehavior>', () => {
if (isNextDev) { if (isNextDev) {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E863",
"description": "\`<Link legacyBehavior>\` received a direct child that is either a Server Component, or JSX that was loaded with React.lazy(). This is not supported. Either remove legacyBehavior, or make the direct child a Client Component that renders the Link's \`<a>\` tag.", "description": "\`<Link legacyBehavior>\` received a direct child that is either a Server Component, or JSX that was loaded with React.lazy(). This is not supported. Either remove legacyBehavior, or make the direct child a Client Component that renders the Link's \`<a>\` tag.",
"environmentLabel": null, "environmentLabel": null,
"label": "Runtime Error", "label": "Runtime Error",
......
...@@ -31,6 +31,7 @@ describe('New Link Behavior with <a> child', () => { ...@@ -31,6 +31,7 @@ describe('New Link Behavior with <a> child', () => {
) )
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E394",
"description": "Invalid <Link> with <a> child. Please remove <a> or use <Link legacyBehavior>. "description": "Invalid <Link> with <a> child. Please remove <a> or use <Link legacyBehavior>.
Learn more: https://nextjs.org/docs/messages/invalid-new-link-with-extra-anchor", Learn more: https://nextjs.org/docs/messages/invalid-new-link-with-extra-anchor",
"environmentLabel": null, "environmentLabel": null,
......
...@@ -15,6 +15,7 @@ describe('next-link', () => { ...@@ -15,6 +15,7 @@ describe('next-link', () => {
if (isNextDev) { if (isNextDev) {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E319",
"description": "Failed prop type: The prop \`href\` expects a \`string\` or \`object\` in \`<Link>\`, but got \`undefined\` instead. "description": "Failed prop type: The prop \`href\` expects a \`string\` or \`object\` in \`<Link>\`, but got \`undefined\` instead.
Open your browser's console to view the Component stack trace.", Open your browser's console to view the Component stack trace.",
"environmentLabel": null, "environmentLabel": null,
...@@ -40,6 +41,7 @@ describe('next-link', () => { ...@@ -40,6 +41,7 @@ describe('next-link', () => {
if (isNextDev) { if (isNextDev) {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"code": "E319",
"description": "Failed prop type: The prop \`prefetch\` expects a \`boolean | "auto"\` in \`<Link>\`, but got \`string\` instead. "description": "Failed prop type: The prop \`prefetch\` expects a \`boolean | "auto"\` in \`<Link>\`, but got \`string\` instead.
Open your browser's console to view the Component stack trace.", Open your browser's console to view the Component stack trace.",
"environmentLabel": null, "environmentLabel": null,
......
...@@ -84,17 +84,18 @@ describe('server-side dev errors', () => { ...@@ -84,17 +84,18 @@ describe('server-side dev errors', () => {
) )
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"description": "missingVar is not defined", "code": "E394",
"environmentLabel": null, "description": "missingVar is not defined",
"label": "Runtime ReferenceError", "environmentLabel": null,
"source": "pages/gsp.js (6:3) @ getStaticProps "label": "Runtime ReferenceError",
> 6 | missingVar;return { "source": "pages/gsp.js (6:3) @ getStaticProps
| ^", > 6 | missingVar;return {
"stack": [ | ^",
"getStaticProps pages/gsp.js (6:3)", "stack": [
], "getStaticProps pages/gsp.js (6:3)",
} ],
}
`) `)
await fs.writeFile(gspPage, content, { flush: true }) await fs.writeFile(gspPage, content, { flush: true })
...@@ -134,17 +135,18 @@ describe('server-side dev errors', () => { ...@@ -134,17 +135,18 @@ describe('server-side dev errors', () => {
) )
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"description": "missingVar is not defined", "code": "E394",
"environmentLabel": null, "description": "missingVar is not defined",
"label": "Runtime ReferenceError", "environmentLabel": null,
"source": "pages/gssp.js (6:3) @ getServerSideProps "label": "Runtime ReferenceError",
> 6 | missingVar;return { "source": "pages/gssp.js (6:3) @ getServerSideProps
| ^", > 6 | missingVar;return {
"stack": [ | ^",
"getServerSideProps pages/gssp.js (6:3)", "stack": [
], "getServerSideProps pages/gssp.js (6:3)",
} ],
}
`) `)
await fs.writeFile(gsspPage, content) await fs.writeFile(gsspPage, content)
...@@ -184,17 +186,18 @@ describe('server-side dev errors', () => { ...@@ -184,17 +186,18 @@ describe('server-side dev errors', () => {
) )
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"description": "missingVar is not defined", "code": "E394",
"environmentLabel": null, "description": "missingVar is not defined",
"label": "Runtime ReferenceError", "environmentLabel": null,
"source": "pages/blog/[slug].js (6:3) @ getServerSideProps "label": "Runtime ReferenceError",
> 6 | missingVar;return { "source": "pages/blog/[slug].js (6:3) @ getServerSideProps
| ^", > 6 | missingVar;return {
"stack": [ | ^",
"getServerSideProps pages/blog/[slug].js (6:3)", "stack": [
], "getServerSideProps pages/blog/[slug].js (6:3)",
} ],
}
`) `)
await fs.writeFile(dynamicGsspPage, content) await fs.writeFile(dynamicGsspPage, content)
...@@ -244,17 +247,18 @@ describe('server-side dev errors', () => { ...@@ -244,17 +247,18 @@ describe('server-side dev errors', () => {
} }
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"description": "missingVar is not defined", "code": "E394",
"environmentLabel": null, "description": "missingVar is not defined",
"label": "Runtime ReferenceError", "environmentLabel": null,
"source": "pages/api/hello.js (2:3) @ handler "label": "Runtime ReferenceError",
> 2 | missingVar;res.status(200).json({ hello: 'world' }) "source": "pages/api/hello.js (2:3) @ handler
| ^", > 2 | missingVar;res.status(200).json({ hello: 'world' })
"stack": [ | ^",
"handler pages/api/hello.js (2:3)", "stack": [
], "handler pages/api/hello.js (2:3)",
} ],
}
`) `)
await fs.writeFile(apiPage, content, { flush: true }) await fs.writeFile(apiPage, content, { flush: true })
...@@ -310,17 +314,18 @@ describe('server-side dev errors', () => { ...@@ -310,17 +314,18 @@ describe('server-side dev errors', () => {
} }
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"description": "missingVar is not defined", "code": "E394",
"environmentLabel": null, "description": "missingVar is not defined",
"label": "Runtime ReferenceError", "environmentLabel": null,
"source": "pages/api/blog/[slug].js (2:3) @ handler "label": "Runtime ReferenceError",
> 2 | missingVar;res.status(200).json({ slug: req.query.slug }) "source": "pages/api/blog/[slug].js (2:3) @ handler
| ^", > 2 | missingVar;res.status(200).json({ slug: req.query.slug })
"stack": [ | ^",
"handler pages/api/blog/[slug].js (2:3)", "stack": [
], "handler pages/api/blog/[slug].js (2:3)",
} ],
}
`) `)
await fs.writeFile(dynamicApiPage, content, { flush: true }) await fs.writeFile(dynamicApiPage, content, { flush: true })
......
...@@ -7,6 +7,7 @@ import { ...@@ -7,6 +7,7 @@ import {
getRedboxComponentStack, getRedboxComponentStack,
getRedboxDescription, getRedboxDescription,
getRedboxEnvironmentLabel, getRedboxEnvironmentLabel,
getRedboxErrorCode,
getRedboxSource, getRedboxSource,
getRedboxLabel, getRedboxLabel,
getRedboxTotalErrorCount, getRedboxTotalErrorCount,
...@@ -86,6 +87,7 @@ export interface ErrorSnapshot { ...@@ -86,6 +87,7 @@ export interface ErrorSnapshot {
description?: string description?: string
componentStack?: string componentStack?: string
cause?: SanitizedCauseEntry[] cause?: SanitizedCauseEntry[]
code?: string
source: string | null source: string | null
stack: string[] | null stack: string[] | null
} }
...@@ -191,6 +193,7 @@ async function createErrorSnapshot( ...@@ -191,6 +193,7 @@ async function createErrorSnapshot(
stack, stack,
componentStack, componentStack,
cause, cause,
code,
] = await Promise.all([ ] = await Promise.all([
includeLabel ? getRedboxLabel(browser) : null, includeLabel ? getRedboxLabel(browser) : null,
getRedboxEnvironmentLabel(browser), getRedboxEnvironmentLabel(browser),
...@@ -199,6 +202,7 @@ async function createErrorSnapshot( ...@@ -199,6 +202,7 @@ async function createErrorSnapshot(
getRedboxCallStack(browser), getRedboxCallStack(browser),
getRedboxComponentStack(browser), getRedboxComponentStack(browser),
getRedboxCause(browser), getRedboxCause(browser),
getRedboxErrorCode(browser),
]) ])
// We don't need to test the codeframe logic everywhere. // We don't need to test the codeframe logic everywhere.
...@@ -253,6 +257,10 @@ async function createErrorSnapshot( ...@@ -253,6 +257,10 @@ async function createErrorSnapshot(
snapshot.componentStack = componentStack snapshot.componentStack = componentStack
} }
if (code !== null) {
snapshot.code = code
}
// Error.cause chain is only relevant when present. // Error.cause chain is only relevant when present.
if (cause !== null) { if (cause !== null) {
snapshot.cause = cause.map((entry) => { snapshot.cause = cause.map((entry) => {
......
...@@ -1193,6 +1193,22 @@ export function getRedboxDescription( ...@@ -1193,6 +1193,22 @@ export function getRedboxDescription(
}) })
} }
export function getRedboxErrorCode(
browser: Playwright
): Promise<string | null> {
return browser.eval(() => {
const portal = [].slice
.call(document.querySelectorAll('nextjs-portal'))
.find((p) => p.shadowRoot.querySelector('[data-nextjs-dialog-header]'))
const root = portal.shadowRoot
return (
root
.querySelector('[data-nextjs-error-code]')
?.getAttribute('data-nextjs-error-code') ?? null
)
})
}
export function getRedboxDescriptionWarning( export function getRedboxDescriptionWarning(
browser: Playwright browser: Playwright
): Promise<string | null> { ): Promise<string | null> {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment