Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[Turbopack] add ./ to relative paths to make it easier to understand #73585

Draft
wants to merge 1 commit into
base: canary
Choose a base branch
from

Conversation

sokra
Copy link
Member

@sokra sokra commented Dec 6, 2024

No description provided.

Copy link
Member Author

sokra commented Dec 6, 2024

@sokra sokra changed the title add ./ to relative paths to make it easier to understand [Turbopack] add ./ to relative paths to make it easier to understand Dec 6, 2024
@ijjk
Copy link
Member

ijjk commented Dec 6, 2024

Failing test suites

Commit: 7a2261c

pnpm test-dev-turbo test/development/app-dir/dynamic-error-trace/index.test.ts (turbopack)

  • app dir - dynamic error trace > should show the error trace
Expand output

● app dir - dynamic error trace › should show the error trace

expect(received).toEqual(expected) // deep equality

- Expected  - 1
+ Received  + 1

@@ -1,6 +1,6 @@
- app/lib.js (4:13) @ Foo
+ ./app/lib.js (4:13) @ Foo

    2 |
    3 | export function Foo() {
  > 4 |   useHeaders()
      |             ^

  39 |
  40 |     const codeframe = await getRedboxSource(browser)
> 41 |     expect(codeframe).toEqual(
     |                       ^
  42 |       process.env.TURBOPACK
  43 |         ? outdent`
  44 |             app/lib.js (4:13) @ Foo

  at Object.toEqual (development/app-dir/dynamic-error-trace/index.test.ts:41:23)

Read more about building and testing Next.js in contributing.md.

pnpm test-dev-turbo test/development/app-dir/server-navigation-error/server-navigation-error.test.ts (turbopack)

  • server-navigation-error > middleware > should error on navigation API redirect
  • server-navigation-error > middleware > should error on navigation API not-found
  • server-navigation-error > pages router > should error on navigation API redirect
  • server-navigation-error > pages router > should error on navigation API notFound
Expand output

● server-navigation-error › pages router › should error on navigation API redirect

expect(received).toMatchInlineSnapshot(snapshot)

Snapshot name: `server-navigation-error pages router should error on navigation API redirect 1`

- Snapshot  - 1
+ Received  + 1

@@ -1,6 +1,6 @@
- pages/pages/redirect.tsx (4:10) @ Page
+ ./pages/pages/redirect.tsx (4:10) @ Page

    2 |
    3 | export default function Page() {
  > 4 |   redirect('/')
      |          ^

  20 |       const source = await getRedboxSource(browser)
  21 |       if (process.env.TURBOPACK) {
> 22 |         expect(source).toMatchInlineSnapshot(`
     |                        ^
  23 |           "pages/pages/redirect.tsx (4:10) @ Page
  24 |
  25 |             2 |

  at Object.toMatchInlineSnapshot (development/app-dir/server-navigation-error/server-navigation-error.test.ts:22:24)

● server-navigation-error › pages router › should error on navigation API notFound

expect(received).toMatchInlineSnapshot(snapshot)

Snapshot name: `server-navigation-error pages router should error on navigation API notFound 1`

- Snapshot  - 1
+ Received  + 1

@@ -1,6 +1,6 @@
- pages/pages/not-found.tsx (4:10) @ Page
+ ./pages/pages/not-found.tsx (4:10) @ Page

    2 |
    3 | export default function Page() {
  > 4 |   notFound()
      |          ^

  52 |       const source = await getRedboxSource(browser)
  53 |       if (process.env.TURBOPACK) {
> 54 |         expect(source).toMatchInlineSnapshot(`
     |                        ^
  55 |           "pages/pages/not-found.tsx (4:10) @ Page
  56 |
  57 |             2 |

  at Object.toMatchInlineSnapshot (development/app-dir/server-navigation-error/server-navigation-error.test.ts:54:24)

● server-navigation-error › middleware › should error on navigation API redirect

expect(received).toMatchInlineSnapshot(snapshot)

Snapshot name: `server-navigation-error middleware should error on navigation API redirect  1`

- Snapshot  - 1
+ Received  + 1

@@ -1,6 +1,6 @@
- middleware.ts (8:12) @ middleware
+ ./middleware.ts (8:12) @ middleware

     6 |     notFound()
     7 |   } else if (req.nextUrl.pathname === '/middleware/redirect') {
  >  8 |     redirect('/')
       |            ^

  88 |       const source = await getRedboxSource(browser)
  89 |       if (process.env.TURBOPACK) {
> 90 |         expect(source).toMatchInlineSnapshot(`
     |                        ^
  91 |           "middleware.ts (8:12) @ middleware
  92 |
  93 |              6 |     notFound()

  at Object.toMatchInlineSnapshot (development/app-dir/server-navigation-error/server-navigation-error.test.ts:90:24)

● server-navigation-error › middleware › should error on navigation API not-found

expect(received).toMatchInlineSnapshot(snapshot)

Snapshot name: `server-navigation-error middleware should error on navigation API not-found 1`

- Snapshot  - 1
+ Received  + 1

@@ -1,6 +1,6 @@
- middleware.ts (6:12) @ middleware
+ ./middleware.ts (6:12) @ middleware

    4 | export default function middleware(req: NextRequest) {
    5 |   if (req.nextUrl.pathname === '/middleware/not-found') {
  > 6 |     notFound()
      |            ^

  123 |
  124 |       if (process.env.TURBOPACK) {
> 125 |         expect(source).toMatchInlineSnapshot(`
      |                        ^
  126 |           "middleware.ts (6:12) @ middleware
  127 |
  128 |             4 | export default function middleware(req: NextRequest) {

  at Object.toMatchInlineSnapshot (development/app-dir/server-navigation-error/server-navigation-error.test.ts:125:24)

Read more about building and testing Next.js in contributing.md.

pnpm test-dev-turbo test/development/app-dir/capture-console-error/capture-console-error.test.ts (turbopack)

  • app-dir - capture-console-error > should capture browser console error and format the error message
  • app-dir - capture-console-error > should capture browser console error in render and dedupe if necessary
  • app-dir - capture-console-error > should capture browser console error in render and dedupe when multi same errors logged
  • app-dir - capture-console-error > should capture server replay string error from console error
  • app-dir - capture-console-error > should capture server replay error instance from console error
  • app-dir - capture-console-error > should be able to capture rsc logged error
Expand output

● app-dir - capture-console-error › should capture browser console error and format the error message

expect(received).toMatchInlineSnapshot(snapshot)

Snapshot name: `app-dir - capture-console-error should capture browser console error and format the error message 1`

- Snapshot  - 1
+ Received  + 1

@@ -1,10 +1,10 @@
  {
    "callStacks": "",
    "count": 1,
    "description": "trigger an console <error>",
-   "source": "app/browser/event/page.js (7:17) @ onClick
+   "source": "./app/browser/event/page.js (7:17) @ onClick

     5 |     <button
     6 |       onClick={() => {
  >  7 |         console.error('trigger an console <%s>', 'error')
       |                 ^

  49 |
  50 |     if (process.env.TURBOPACK) {
> 51 |       expect(result).toMatchInlineSnapshot(`
     |                      ^
  52 |         {
  53 |           "callStacks": "",
  54 |           "count": 1,

  at Object.toMatchInlineSnapshot (development/app-dir/capture-console-error/capture-console-error.test.ts:51:22)

● app-dir - capture-console-error › should capture browser console error in render and dedupe if necessary

expect(received).toMatchInlineSnapshot(snapshot)

Snapshot name: `app-dir - capture-console-error should capture browser console error in render and dedupe if necessary 1`

- Snapshot  - 1
+ Received  + 1

@@ -1,10 +1,10 @@
  {
    "callStacks": "",
    "count": 2,
    "description": "trigger an console.error in render",
-   "source": "app/browser/render/page.js (4:11) @ Page
+   "source": "./app/browser/render/page.js (4:11) @ Page

    2 |
    3 | export default function Page() {
  > 4 |   console.error('trigger an console.error in render')
      |           ^

   95 |
   96 |     if (process.env.TURBOPACK) {
>  97 |       expect(result).toMatchInlineSnapshot(`
      |                      ^
   98 |         {
   99 |           "callStacks": "",
  100 |           "count": 2,

  at Object.toMatchInlineSnapshot (development/app-dir/capture-console-error/capture-console-error.test.ts:97:22)

● app-dir - capture-console-error › should capture browser console error in render and dedupe when multi same errors logged

expect(received).toMatchInlineSnapshot(snapshot)

Snapshot name: `app-dir - capture-console-error should capture browser console error in render and dedupe when multi same errors logged 1`

- Snapshot  - 1
+ Received  + 1

@@ -1,10 +1,10 @@
  {
    "callStacks": "",
    "count": 2,
    "description": "trigger an console.error in render",
-   "source": "app/browser/render/page.js (4:11) @ Page
+   "source": "./app/browser/render/page.js (4:11) @ Page

    2 |
    3 | export default function Page() {
  > 4 |   console.error('trigger an console.error in render')
      |           ^

  141 |
  142 |     if (process.env.TURBOPACK) {
> 143 |       expect(result).toMatchInlineSnapshot(`
      |                      ^
  144 |         {
  145 |           "callStacks": "",
  146 |           "count": 2,

  at Object.toMatchInlineSnapshot (development/app-dir/capture-console-error/capture-console-error.test.ts:143:22)

● app-dir - capture-console-error › should capture server replay string error from console error

expect(received).toMatchInlineSnapshot(snapshot)

Snapshot name: `app-dir - capture-console-error should capture server replay string error from console error 1`

- Snapshot  - 1
+ Received  + 1

@@ -1,10 +1,10 @@
  {
    "callStacks": "",
    "count": 2,
    "description": "ssr console error:client",
-   "source": "app/ssr/page.js (4:11) @ Page
+   "source": "./app/ssr/page.js (4:11) @ Page

    2 |
    3 | export default function Page() {
  > 4 |   console.error(
      |           ^

  187 |
  188 |     if (process.env.TURBOPACK) {
> 189 |       expect(result).toMatchInlineSnapshot(`
      |                      ^
  190 |         {
  191 |           "callStacks": "",
  192 |           "count": 2,

  at Object.toMatchInlineSnapshot (development/app-dir/capture-console-error/capture-console-error.test.ts:189:22)

● app-dir - capture-console-error › should capture server replay error instance from console error

expect(received).toMatchInlineSnapshot(snapshot)

Snapshot name: `app-dir - capture-console-error should capture server replay error instance from console error 1`

- Snapshot  - 1
+ Received  + 1

@@ -1,10 +1,10 @@
  {
    "callStacks": "",
    "count": 2,
    "description": "Error: page error",
-   "source": "app/ssr-error-instance/page.js (4:17) @ Page
+   "source": "./app/ssr-error-instance/page.js (4:17) @ Page

    2 |
    3 | export default function Page() {
  > 4 |   console.error(new Error('page error'))
      |                 ^

  233 |
  234 |     if (process.env.TURBOPACK) {
> 235 |       expect(result).toMatchInlineSnapshot(`
      |                      ^
  236 |         {
  237 |           "callStacks": "",
  238 |           "count": 2,

  at Object.toMatchInlineSnapshot (development/app-dir/capture-console-error/capture-console-error.test.ts:235:22)

● app-dir - capture-console-error › should be able to capture rsc logged error

expect(received).toMatchInlineSnapshot(snapshot)

Snapshot name: `app-dir - capture-console-error should be able to capture rsc logged error 1`

- Snapshot  - 1
+ Received  + 1

@@ -1,11 +1,11 @@
  {
    "callStacks": "JSON.parse
  <anonymous> (0:0)",
    "count": 1,
    "description": "[ Server ] Error: boom",
-   "source": "app/rsc/page.js (2:17) @ Page
+   "source": "./app/rsc/page.js (2:17) @ Page

    1 | export default function Page() {
  > 2 |   console.error(new Error('boom'))
      |                 ^
    3 |   return <p>rsc</p>

  279 |
  280 |     if (process.env.TURBOPACK) {
> 281 |       expect(result).toMatchInlineSnapshot(`
      |                      ^
  282 |         {
  283 |           "callStacks": "JSON.parse
  284 |         <anonymous> (0:0)",

  at Object.toMatchInlineSnapshot (development/app-dir/capture-console-error/capture-console-error.test.ts:281:22)

Read more about building and testing Next.js in contributing.md.

pnpm test-dev-turbo test/development/acceptance/error-recovery.test.ts (turbopack)

  • ReactRefreshLogBox turbo > logbox: can recover from a event handler error
  • ReactRefreshLogBox turbo > syntax > runtime error
Expand output

● ReactRefreshLogBox turbo › logbox: can recover from a event handler error

expect(received).toMatchInlineSnapshot(snapshot)

Snapshot name: `ReactRefreshLogBox turbo logbox: can recover from a event handler error 1`

- Snapshot  - 1
+ Received  + 1

@@ -1,6 +1,6 @@
- index.js (7:11) @ Index.useCallback[increment]
+ ./index.js (7:11) @ Index.useCallback[increment]

     5 |   const increment = useCallback(() => {
     6 |     setCount(c => c + 1)
  >  7 |     throw new Error('oops')
       |           ^

  107 |     await session.assertHasRedbox()
  108 |     if (isTurbopack) {
> 109 |       expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
      |                                               ^
  110 |         "index.js (7:11) @ Index.useCallback[increment]
  111 |
  112 |            5 |   const increment = useCallback(() => {

  at Object.toMatchInlineSnapshot (development/acceptance/error-recovery.test.ts:109:47)

● ReactRefreshLogBox turbo › syntax > runtime error

expect(received).toMatchSnapshot()

Snapshot name: `ReactRefreshLogBox turbo syntax > runtime error 1`

- Snapshot  - 1
+ Received  + 1

@@ -1,6 +1,6 @@
- index.js (5:9) @ eval
+ ./index.js (5:9) @ eval

    3 | setInterval(() => {
    4 |   i++
  > 5 |   throw Error('no ' + i)
      |         ^

  410 |       expect(await session.getRedboxSource()).toMatchSnapshot()
  411 |     } else {
> 412 |       expect(await session.getRedboxSource()).toMatchSnapshot()
      |                                               ^
  413 |     }
  414 |
  415 |     // Make a syntax error.

  at Object.toMatchSnapshot (development/acceptance/error-recovery.test.ts:412:47)

Read more about building and testing Next.js in contributing.md.

pnpm test-dev test/e2e/app-dir/use-cache-close-over-function/use-cache-close-over-function.test.ts

  • use-cache-close-over-function > should show an error toast for client-side usage
  • use-cache-close-over-function > should show the error overlay for server-side usage
Expand output

● use-cache-close-over-function › should show an error toast for client-side usage

expect(received).toContain(expected) // indexOf

Expected substring: "Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with \"use server\". Or maybe you meant to call this function rather than return it.
  [function fn]
   ^^^^^^^^^^^

  at createCachedFn (../app/client/page.tsx:8:2)
  at createCachedFn (../app/client/page.tsx:15:27)
     6 |   }
     7 |
  >  8 |   return async () => {
       |  ^
     9 |     'use cache'
    10 |     return Math.random() + fn()
    11 |   }"
  Received string:    " ○ Compiling /client ...
   ✓ Compiled /client in 4.2s (698 modules)
  Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with \"use server\". Or maybe you meant to call this function rather than return it.
    [function fn]
     ^^^^^^^^^^^
  at createCachedFn (../app/client/page.tsx:8:2)
  at createCachedFn (../app/client/page.tsx:15:27)
     6 |   }
     7 |
  >  8 |   return async () => {
       |  ^
     9 |     'use cache'
    10 |     return Math.random() + fn()
    11 |   }
   ⨯ Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with \"use server\". Or maybe you meant to call this function rather than return it.
    [function fn]
     ^^^^^^^^^^^
  at createCachedFn (../app/client/page.tsx:8:2)
  at createCachedFn (../app/client/page.tsx:15:27)
     6 |   }
     7 |
  >  8 |   return async () => {
       |  ^
     9 |     'use cache'
    10 |     return Math.random() + fn()
    11 |   } {
    digest: '3852446453'
  }
  Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with \"use server\". Or maybe you meant to call this function rather than return it.
    [function fn]
     ^^^^^^^^^^^
  at createCachedFn (../app/client/page.tsx:8:2)
  at createCachedFn (../app/client/page.tsx:15:27)
     6 |   }
     7 |
  >  8 |   return async () => {
       |  ^
     9 |     'use cache'
    10 |     return Math.random() + fn()
    11 |   }
  Failed to serialize an action for progressive enhancement:
  Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with \"use server\". Or maybe you meant to call this function rather than return it.
    [function fn]
     ^^^^^^^^^^^
  at createCachedFn (../app/client/page.tsx:8:2)
  at createCachedFn (../app/client/page.tsx:15:27)
     6 |   }
     7 |
  >  8 |   return async () => {
       |  ^
     9 |     'use cache'
    10 |     return Math.random() + fn()
    11 |   } {
    environmentName: 'Prerender',
    digest: '3852446453'
  }
  Failed to serialize an action for progressive enhancement:
  Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with \"use server\". Or maybe you meant to call this function rather than return it.
    [function fn]
     ^^^^^^^^^^^
  at createCachedFn (../app/client/page.tsx:8:2)
  at createCachedFn (../app/client/page.tsx:15:27)
     6 |   }
     7 |
  >  8 |   return async () => {
       |  ^
     9 |     'use cache'
    10 |     return Math.random() + fn()
    11 |   } {
    environmentName: 'Server',
    digest: ''
  }
  Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with \"use server\". Or maybe you meant to call this function rather than return it.
    [function fn]
     ^^^^^^^^^^^
  at createCachedFn (../app/client/page.tsx:8:2)
  at createCachedFn (../app/client/page.tsx:15:27)
     6 |   }
     7 |
  >  8 |   return async () => {
       |  ^
     9 |     'use cache'
    10 |     return Math.random() + fn()
    11 |   }
  Failed to serialize an action for progressive enhancement:
  Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with \"use server\". Or maybe you meant to call this function rather than return it.
    [function fn]
     ^^^^^^^^^^^
  at createCachedFn (../app/client/page.tsx:8:2)
  at createCachedFn (../app/client/page.tsx:15:27)
     6 |   }
     7 |
  >  8 |   return async () => {
       |  ^
     9 |     'use cache'
    10 |     return Math.random() + fn()
    11 |   } {
    environmentName: 'Server',
    digest: ''
  }
   GET /client 200 in 5942ms
  "
  at Object.toContain (e2e/app-dir/use-cache-close-over-function/use-cache-close-over-function.test.ts:50:25)

● use-cache-close-over-function › should show the error overlay for server-side usage

expect(received).toContain(expected) // indexOf

Expected substring: "Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with \"use server\". Or maybe you meant to call this function rather than return it.
  [function fn]
   ^^^^^^^^^^^

  at createCachedFn (../app/server/page.tsx:6:2)
  at createCachedFn (../app/server/page.tsx:12:23)
      at (rsc)"
  Received string:    " ✓ Compiled /server in 413ms (701 modules)
  Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with \"use server\". Or maybe you meant to call this function rather than return it.
    [function fn]
     ^^^^^^^^^^^
  at createCachedFn (../app/server/page.tsx:6:2)
  at createCachedFn (../app/server/page.tsx:12:23)
  at (rsc)/./app/server/page.tsx (../.next/server/app/server/page.js:183:1)
  at Function.__webpack_require__ (../.next/server/webpack-runtime.js:33:42)
    4 |   }
    5 |
  > 6 |   return async () => {
      |  ^
    7 |     'use cache'
    8 |     return Math.random() + fn()
    9 |   }
  Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with \"use server\". Or maybe you meant to call this function rather than return it.
    [function fn]
     ^^^^^^^^^^^
  at createCachedFn (../app/server/page.tsx:6:2)
  at createCachedFn (../app/server/page.tsx:12:23)
  at (rsc)/./app/server/page.tsx (../.next/server/app/server/page.js:183:1)
  at Function.__webpack_require__ (../.next/server/webpack-runtime.js:33:42)
    4 |   }
    5 |
  > 6 |   return async () => {
      |  ^
    7 |     'use cache'
    8 |     return Math.random() + fn()
    9 |   }
   ⨯ unhandledRejection: Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with \"use server\". Or maybe you meant to call this function rather than return it.
    [function fn]
     ^^^^^^^^^^^
  at createCachedFn (../app/server/page.tsx:6:2)
  at createCachedFn (../app/server/page.tsx:12:23)
  at (rsc)/./app/server/page.tsx (../.next/server/app/server/page.js:183:1)
  at Function.__webpack_require__ (../.next/server/webpack-runtime.js:33:42)
    4 |   }
    5 |
  > 6 |   return async () => {
      |  ^
    7 |     'use cache'
    8 |     return Math.random() + fn()
    9 |   }
   ⨯ unhandledRejection:  Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with \"use server\". Or maybe you meant to call this function rather than return it.
    [function fn]
     ^^^^^^^^^^^
  at createCachedFn (../app/server/page.tsx:6:2)
  at createCachedFn (../app/server/page.tsx:12:23)
  at (rsc)/./app/server/page.tsx (../.next/server/app/server/page.js:183:1)
  at Function.__webpack_require__ (../.next/server/webpack-runtime.js:33:42)
    4 |   }
    5 |
  > 6 |   return async () => {
      |  ^
    7 |     'use cache'
    8 |     return Math.random() + fn()
    9 |   }
   ⨯ Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with \"use server\". Or maybe you meant to call this function rather than return it.
    [function fn]
     ^^^^^^^^^^^
  at createCachedFn (../app/server/page.tsx:6:2)
  at createCachedFn (../app/server/page.tsx:12:23)
  at (rsc)/./app/server/page.tsx (../.next/server/app/server/page.js:183:1)
  at Function.__webpack_require__ (../.next/server/webpack-runtime.js:33:42)
    4 |   }
    5 |
  > 6 |   return async () => {
      |  ^
    7 |     'use cache'
    8 |     return Math.random() + fn()
    9 |   } {
    digest: '1116380737'
  }
   GET /server 200 in 1972ms
  "
  at Object.toContain (e2e/app-dir/use-cache-close-over-function/use-cache-close-over-function.test.ts:109:25)

Read more about building and testing Next.js in contributing.md.

pnpm test-dev test/e2e/app-dir/server-source-maps/server-source-maps-edge.test.ts

  • app-dir - server source maps edge runtime > logged errors have a sourcemapped stack with a codeframe
  • app-dir - server source maps edge runtime > thrown SSR errors
  • app-dir - server source maps edge runtime > should log the correct values on app-render error
Expand output

● app-dir - server source maps edge runtime › logged errors have a sourcemapped stack with a codeframe

expect(received).toContain(expected) // indexOf

Expected substring: "
Error: Boom

  at logError (../app/rsc-error-log/page.js:2:16)
  at logError (../app/rsc-error-log/page.js:6:2)
    1 | function logError() {
  > 2 |   console.error(new Error('Boom'))
      |                ^
    3 | }
    4 |
    5 | export default function Page() { {···
  }"
  Received string:    " ○ Compiling /rsc-error-log ...
   ✓ Compiled /rsc-error-log in 6.1s (988 modules)
  Error: Boom
  at logError (../app/rsc-error-log/page.js:2:16)
  at logError (../app/rsc-error-log/page.js:6:2)
    1 | function logError() {
  > 2 |   console.error(new Error('Boom'))
      |                ^
    3 | }
    4 |
    5 | export default function Page() { {···
  }
  "
  at Object.toContain (e2e/app-dir/server-source-maps/server-source-maps-edge.test.ts:29:69)

● app-dir - server source maps edge runtime › thrown SSR errors

expect(received).toContain(expected) // indexOf

Expected substring: "
 ⨯ Error: Boom

  at throwError (../app/ssr-throw/page.js:4:8)
  at throwError (../app/ssr-throw/page.js:8:2)
    2 |
    3 | function throwError() {
  > 4 |   throw new Error('Boom')
      |        ^
    5 | }
    6 |
    7 | export default function Page() { {
    digest: '"
  Received string:    " GET /rsc-error-log 200 in 6679ms
   ○ Compiling /ssr-throw ...
   ✓ Compiled /ssr-throw in 3.4s (996 modules)
   ⨯ Error: Boom
  at throwError (../app/ssr-throw/page.js:4:8)
  at throwError (../app/ssr-throw/page.js:8:2)
    2 |
    3 | function throwError() {
  > 4 |   throw new Error('Boom')
      |        ^
    5 | }
    6 |
    7 | export default function Page() { {
    digest: '3946376972'
  }
  "
  at Object.toContain (e2e/app-dir/server-source-maps/server-source-maps-edge.test.ts:69:25)

● app-dir - server source maps edge runtime › should log the correct values on app-render error

expect(received).toContain(expected) // indexOf

Expected substring: "
 ⨯ Error: Boom

  at throwError (../app/rsc-throw/page.js:2:8)
  at throwError (../app/rsc-throw/page.js:6:2)
    1 | function throwError() {
  > 2 |   throw new Error('Boom')
      |        ^
    3 | }
    4 |
    5 | export default function Page() { {
    digest: '"
  Received string:    " GET /ssr-throw 500 in 3936ms
   ✓ Compiled /rsc-throw in 349ms (999 modules)
   ⨯ Error: Boom
  at throwError (../app/rsc-throw/page.js:2:8)
  at throwError (../app/rsc-throw/page.js:6:2)
    1 | function throwError() {
  > 2 |   throw new Error('Boom')
      |        ^
    3 | }
    4 |
    5 | export default function Page() { {
    digest: '3418968191'
  }
  "
  at Object.toContain (e2e/app-dir/server-source-maps/server-source-maps-edge.test.ts:111:25)

Read more about building and testing Next.js in contributing.md.

pnpm test-dev test/e2e/app-dir/server-source-maps/server-source-maps.test.ts

  • app-dir - server source maps > logged errors have a sourcemapped stack with a codeframe
  • app-dir - server source maps > logged errors have a sourcemapped cause
  • app-dir - server source maps > stack frames are ignore-listed in ssr
  • app-dir - server source maps > stack frames are ignore-listed in rsc
  • app-dir - server source maps > thrown SSR errors
Expand output

● app-dir - server source maps › logged errors have a sourcemapped stack with a codeframe

expect(received).toContain(expected) // indexOf

Expected substring: "
Error: Boom

  at logError (../app/rsc-error-log/page.js:4:16)
  at logError (../app/rsc-error-log/page.js:11:2)
    2 |
    3 | function logError() {
  > 4 |   const error = new Error('Boom')
      |                ^
    5 |   console.error(error)
    6 | }
    7 |
  "
  Received string:    " ○ Compiling /rsc-error-log ...
   ✓ Compiled /rsc-error-log in 6s (689 modules)
  Error: Boom
  at logError (../app/rsc-error-log/page.js:4:16)
  at logError (../app/rsc-error-log/page.js:11:2)
    2 |
    3 | function logError() {
  > 4 |   const error = new Error('Boom')
      |                ^
    5 |   console.error(error)
    6 | }
    7 |
  "
  at Object.toContain (e2e/app-dir/server-source-maps/server-source-maps.test.ts:37:69)

● app-dir - server source maps › logged errors have a sourcemapped cause

expect(received).toContain(expected) // indexOf

Expected substring: "
Error: Boom

  at logError (../app/rsc-error-log-cause/page.js:4:16)
  at logError (../app/rsc-error-log-cause/page.js:12:2)
    2 |
    3 | function logError(cause) {
  > 4 |   const error = new Error('Boom', { cause })
      |                ^
    5 |   console.error(error)
    6 | }
    7 | {
    [cause]: Error: Boom
  at Page (../app/rsc-error-log-cause/page.js:11:16)
       9 |   await connection()
      10 |
    > 11 |   const error = new Error('Boom')
         |                ^
      12 |   logError(error)
      13 |   return null
      14 | }
  "
  Received string:    " GET /rsc-error-log 200 in 6427ms
   ○ Compiling /rsc-error-log-cause ...
   ✓ Compiled /rsc-error-log-cause in 2.1s (691 modules)
  Error: Boom
  at logError (../app/rsc-error-log-cause/page.js:4:16)
  at logError (../app/rsc-error-log-cause/page.js:12:2)
    2 |
    3 | function logError(cause) {
  > 4 |   const error = new Error('Boom', { cause })
      |                ^
    5 |   console.error(error)
    6 | }
    7 | {
    [cause]: Error: Boom
  at Page (../app/rsc-error-log-cause/page.js:11:16)
       9 |   await connection()
      10 |
    > 11 |   const error = new Error('Boom')
         |                ^
      12 |   logError(error)
      13 |   return null
      14 | }
  }
  "
  at Object.toContain (e2e/app-dir/server-source-maps/server-source-maps.test.ts:66:69)

● app-dir - server source maps › stack frames are ignore-listed in ssr

expect(received).toContain(expected) // indexOf

Expected substring: "
Error: Boom

  at logError (../app/ssr-error-log-ignore-listed/page.js:8:16)
  at logError (../app/ssr-error-log-ignore-listed/page.js:17:10)
  at runWithExternal (../app/ssr-error-log-ignore-listed/page.js:16:32)
  at runWithInternalSourceMapped (../app/ssr-error-log-ignore-listed/page.js:15:18)
  at runWithInternal (../app/ssr-error-log-ignore-listed/page.js:14:28)
  at Page (../app/ssr-error-log-ignore-listed/page.js:13:14)
     6 |
  "
  Received string:    " GET /rsc-error-log-cause 200 in 2231ms
   ✓ Compiled /ssr-error-log-ignore-listed in 346ms (707 modules)
  Error: Boom
  at logError (../app/ssr-error-log-ignore-listed/page.js:8:16)
  at logError (../app/ssr-error-log-ignore-listed/page.js:17:10)
  at runWithExternal (../app/ssr-error-log-ignore-listed/page.js:16:32)
  at runWithInternalSourceMapped (../app/ssr-error-log-ignore-listed/page.js:15:18)
  at runWithInternal (../app/ssr-error-log-ignore-listed/page.js:14:28)
  at Page (../app/ssr-error-log-ignore-listed/page.js:13:14)
     6 |
     7 | function logError() {
  >  8 |   const error = new Error('Boom')
       |                ^
     9 |   console.error(error)
    10 | }
    11 |
  Error: Boom
  at logError (../app/ssr-error-log-ignore-listed/page.js:8:16)
  at logError (../app/ssr-error-log-ignore-listed/page.js:17:10)
  at runWithExternal (../app/ssr-error-log-ignore-listed/page.js:16:32)
  at runWithInternalSourceMapped (../app/ssr-error-log-ignore-listed/page.js:15:18)
  at runWithInternal (../app/ssr-error-log-ignore-listed/page.js:14:28)
  at Page (../app/ssr-error-log-ignore-listed/page.js:13:14)
     6 |
     7 | function logError() {
  >  8 |   const error = new Error('Boom')
       |                ^
     9 |   console.error(error)
    10 | }
    11 |
  "
  at Object.toContain (e2e/app-dir/server-source-maps/server-source-maps.test.ts:108:71)

● app-dir - server source maps › stack frames are ignore-listed in rsc

expect(received).toContain(expected) // indexOf

Expected substring: "
Error: Boom

  at logError (../app/rsc-error-log-ignore-listed/page.js:8:16)
  at logError (../app/rsc-error-log-ignore-listed/page.js:19:10)
  at runWithExternal (../app/rsc-error-log-ignore-listed/page.js:18:32)
  at runWithInternalSourceMapped (../app/rsc-error-log-ignore-listed/page.js:17:18)
  at runWithInternal (../app/rsc-error-log-ignore-listed/page.js:16:28)
  at Page (../app/rsc-error-log-ignore-listed/page.js:15:14)
     6 |
  "
  Received string:    " GET /ssr-error-log-ignore-listed 200 in 418ms
   ✓ Compiled /rsc-error-log-ignore-listed in 236ms (711 modules)
  Error: Boom
  at logError (../app/rsc-error-log-ignore-listed/page.js:8:16)
  at logError (../app/rsc-error-log-ignore-listed/page.js:19:10)
  at runWithExternal (../app/rsc-error-log-ignore-listed/page.js:18:32)
  at runWithInternalSourceMapped (../app/rsc-error-log-ignore-listed/page.js:17:18)
  at runWithInternal (../app/rsc-error-log-ignore-listed/page.js:16:28)
  at Page (../app/rsc-error-log-ignore-listed/page.js:15:14)
     6 |
     7 | function logError() {
  >  8 |   const error = new Error('Boom')
       |                ^
     9 |   console.error(error)
    10 | }
    11 |
   GET /rsc-error-log-ignore-listed 200 in 312ms
  "
  at Object.toContain (e2e/app-dir/server-source-maps/server-source-maps.test.ts:143:71)

● app-dir - server source maps › thrown SSR errors

expect(received).toContain(expected) // indexOf

Expected substring: "
 ⨯ Error: Boom

  at throwError (../app/ssr-throw/Thrower.js:4:8)
  at throwError (../app/ssr-throw/Thrower.js:8:2)
    2 |
    3 | function throwError() {
  > 4 |   throw new Error('Boom')
      |        ^
    5 | }
    6 |
    7 | export function Thrower() { {
    digest: '"
  Received string:    " ✓ Compiled /ssr-throw in 259ms (719 modules)
   ⨯ Error: Boom
  at throwError (../app/ssr-throw/Thrower.js:4:8)
  at throwError (../app/ssr-throw/Thrower.js:8:2)
    2 |
    3 | function throwError() {
  > 4 |   throw new Error('Boom')
      |        ^
    5 | }
    6 |
    7 | export function Thrower() { {
    digest: '3904149196'
  }
   GET /ssr-throw 200 in 328ms
  "
  at Object.toContain (e2e/app-dir/server-source-maps/server-source-maps.test.ts:174:25)

Read more about building and testing Next.js in contributing.md.

pnpm test-dev-turbo test/development/middleware-errors/index.test.ts (turbopack)

  • middleware - development errors > when middleware contains an unhandled rejection > logs the error correctly
  • middleware - development errors > when middleware throws synchronously > logs the error correctly
  • middleware - development errors > when running invalid dynamic code with eval > logs the error correctly
Expand output

● middleware - development errors › when middleware throws synchronously › logs the error correctly

expect(received).toContain(expected) // indexOf

Expected substring: "
 ⨯ Error: boom

  at __TURBOPACK__default__export__ (../middleware.js:3:14)
    1 |"
  Received string:    "   No config file found
     No config file found
     ▲ Next.js 15.1.1-canary.13 (Turbopack)
     - Local:        http://localhost:37003
     - Network:      http://135.181.236.166:37003·
   ✓ Starting...
     No config file found
  Creating turbopack project {
    dir: '/tmp/next-install-d3bdc9e60872e70ea6d6611569495b98f064a5aea1933349924c9a46e08dcfd9',
    testMode: true
  }
   ✓ Compiled in 150ms
     No config file found
   ✓ Ready in 827ms
     No config file found
   ⨯ Error: boom
  at __TURBOPACK__default__export__ (../middleware.js:3:14)
    1 |
    2 |       export default function () {
  > 3 |         throw new Error('boom')
      |              ^
    4 |       }
   ○ Compiling /_error ...
   ✓ Compiled /_error in 1067ms
  "
  at Object.toContain (development/middleware-errors/index.test.ts:40:41)

● middleware - development errors › when middleware contains an unhandled rejection › logs the error correctly

expect(received).toContain(expected) // indexOf

Expected substring: " ⨯ unhandledRejection:  Error: async boom!

  at throwError (../middleware.js:4:14)
  at __TURBOPACK__default__export__ (../middleware.js:7:8)
    2 |       import { NextResponse } from 'next/server'"
  Received string:    "   No config file found
     No config file found
     ▲ Next.js 15.1.1-canary.13 (Turbopack)
     - Local:        http://localhost:34379
     - Network:      http://135.181.236.166:34379·
   ✓ Starting...
     No config file found
  Creating turbopack project {
    dir: '/tmp/next-install-d3bdc9e60872e70ea6d6611569495b98f064a5aea1933349924c9a46e08dcfd9',
    testMode: true
  }
   ✓ Compiled in 247ms
     No config file found
   ✓ Ready in 1031ms
     No config file found
  Error: async boom!
  at throwError (../middleware.js:4:14)
  at __TURBOPACK__default__export__ (../middleware.js:7:8)
    2 |       import { NextResponse } from 'next/server'
    3 |       async function throwError() {
  > 4 |         throw new Error('async boom!')
      |              ^
    5 |       }
    6 |       export default function () {
    7 |         throwError()
   ⨯ unhandledRejection: Error: async boom!
  at throwError (../middleware.js:4:14)
  at __TURBOPACK__default__export__ (../middleware.js:7:8)
    2 |       import { NextResponse } from 'next/server'
    3 |       async function throwError() {
  > 4 |         throw new Error('async boom!')
      |              ^
    5 |       }
    6 |       export default function () {
    7 |         throwError()
   ⨯ unhandledRejection:  Error: async boom!
  at throwError (../middleware.js:4:14)
  at __TURBOPACK__default__export__ (../middleware.js:7:8)
    2 |       import { NextResponse } from 'next/server'
    3 |       async function throwError() {
  > 4 |         throw new Error('async boom!')
      |              ^
    5 |       }
    6 |       export default function () {
    7 |         throwError()
   ○ Compiling / ...
   ✓ Compiled / in 1118ms
  "
  at Object.toContain (development/middleware-errors/index.test.ts:91:41)

● middleware - development errors › when running invalid dynamic code with eval › logs the error correctly

expect(received).toContain(expected) // indexOf

Expected substring: "
    at __TURBOPACK__default__export__ (.next/"
Received string:    "   No config file found
   No config file found
   ▲ Next.js 15.1.1-canary.13 (Turbopack)
   - Local:        http://localhost:42865
   - Network:      http://135.181.236.166:42865·
 ✓ Starting...
   No config file found
Creating turbopack project {
  dir: '/tmp/next-install-d3bdc9e60872e70ea6d6611569495b98f064a5aea1933349924c9a46e08dcfd9',
  testMode: true
}
 ✓ Compiled in 503ms
   No config file found
 ✓ Ready in 1268ms
   No config file found
 ⚠ DynamicCodeEvaluationWarning: Dynamic Code Evaluation (e. g. 'eval', 'new Function') not allowed in Edge Runtime
Learn More: https://nextjs.org/docs/messages/edge-dynamic-code-evaluation

  at __TURBOPACK__default__export__ (../.next/server/edge/chunks/[root of the server]__28202e._.js:31:5)
   ⨯ Error [ReferenceError]: test is not defined
  at eval (../middleware.js:4:8)
  at <unknown> (../middleware.js:4:8)
  at __TURBOPACK__default__export__ (../.next/server/edge/chunks/[root of the server]__28202e._.js:31:5)
    2 |       import { NextResponse } from 'next/server'
    3 |       export default function () {
  > 4 |         eval('test')
      |        ^
    5 |         return NextResponse.next()
    6 |       }
   ○ Compiling /_error ...
   ✓ Compiled /_error in 1411ms
  "
  at Object.toContain (development/middleware-errors/index.test.ts:141:43)

Read more about building and testing Next.js in contributing.md.

@ijjk
Copy link
Member

ijjk commented Dec 6, 2024

Stats from current PR

Default Build (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary vercel/next.js sokra/dot-slash-prefix-on-relative-paths Change
buildDuration 36.3s 34.1s N/A
buildDurationCached 30.9s 29.4s N/A
nodeModulesSize 416 MB 416 MB ⚠️ +8.09 kB
nextStartRea..uration (ms) 949ms 976ms N/A
Client Bundles (main, webpack)
vercel/next.js canary vercel/next.js sokra/dot-slash-prefix-on-relative-paths Change
1187-HASH.js gzip 52.4 kB 52.4 kB N/A
8276.HASH.js gzip 169 B 168 B N/A
8377-HASH.js gzip 5.36 kB 5.36 kB N/A
bccd1874-HASH.js gzip 53 kB 53 kB N/A
framework-HASH.js gzip 57.5 kB 57.5 kB N/A
main-app-HASH.js gzip 232 B 235 B N/A
main-HASH.js gzip 34.1 kB 34.1 kB N/A
webpack-HASH.js gzip 1.71 kB 1.71 kB N/A
Overall change 0 B 0 B
Legacy Client Bundles (polyfills)
vercel/next.js canary vercel/next.js sokra/dot-slash-prefix-on-relative-paths Change
polyfills-HASH.js gzip 39.4 kB 39.4 kB
Overall change 39.4 kB 39.4 kB
Client Pages
vercel/next.js canary vercel/next.js sokra/dot-slash-prefix-on-relative-paths Change
_app-HASH.js gzip 193 B 193 B
_error-HASH.js gzip 193 B 193 B
amp-HASH.js gzip 512 B 510 B N/A
css-HASH.js gzip 343 B 342 B N/A
dynamic-HASH.js gzip 1.84 kB 1.84 kB
edge-ssr-HASH.js gzip 265 B 265 B
head-HASH.js gzip 363 B 362 B N/A
hooks-HASH.js gzip 393 B 392 B N/A
image-HASH.js gzip 4.49 kB 4.49 kB N/A
index-HASH.js gzip 268 B 268 B
link-HASH.js gzip 2.35 kB 2.34 kB N/A
routerDirect..HASH.js gzip 328 B 328 B
script-HASH.js gzip 397 B 397 B
withRouter-HASH.js gzip 323 B 326 B N/A
1afbb74e6ecf..834.css gzip 106 B 106 B
Overall change 3.59 kB 3.59 kB
Client Build Manifests
vercel/next.js canary vercel/next.js sokra/dot-slash-prefix-on-relative-paths Change
_buildManifest.js gzip 749 B 746 B N/A
Overall change 0 B 0 B
Rendered Page Sizes
vercel/next.js canary vercel/next.js sokra/dot-slash-prefix-on-relative-paths Change
index.html gzip 524 B 524 B
link.html gzip 539 B 537 B N/A
withRouter.html gzip 520 B 521 B N/A
Overall change 524 B 524 B
Edge SSR bundle Size
vercel/next.js canary vercel/next.js sokra/dot-slash-prefix-on-relative-paths Change
edge-ssr.js gzip 129 kB 129 kB N/A
page.js gzip 205 kB 205 kB N/A
Overall change 0 B 0 B
Middleware size
vercel/next.js canary vercel/next.js sokra/dot-slash-prefix-on-relative-paths Change
middleware-b..fest.js gzip 670 B 667 B N/A
middleware-r..fest.js gzip 155 B 156 B N/A
middleware.js gzip 31.3 kB 31.3 kB N/A
edge-runtime..pack.js gzip 844 B 844 B
Overall change 844 B 844 B
Next Runtimes
vercel/next.js canary vercel/next.js sokra/dot-slash-prefix-on-relative-paths Change
274-experime...dev.js gzip 322 B 322 B
274.runtime.dev.js gzip 314 B 314 B
app-page-exp...dev.js gzip 356 kB 356 kB
app-page-exp..prod.js gzip 129 kB 129 kB
app-page-tur..prod.js gzip 142 kB 142 kB
app-page-tur..prod.js gzip 137 kB 137 kB
app-page.run...dev.js gzip 347 kB 347 kB
app-page.run..prod.js gzip 125 kB 125 kB
app-route-ex...dev.js gzip 37.5 kB 37.5 kB
app-route-ex..prod.js gzip 25.5 kB 25.5 kB
app-route-tu..prod.js gzip 25.5 kB 25.5 kB
app-route-tu..prod.js gzip 25.3 kB 25.3 kB
app-route.ru...dev.js gzip 39.1 kB 39.1 kB
app-route.ru..prod.js gzip 25.3 kB 25.3 kB
pages-api-tu..prod.js gzip 9.69 kB 9.69 kB
pages-api.ru...dev.js gzip 11.6 kB 11.6 kB
pages-api.ru..prod.js gzip 9.68 kB 9.68 kB
pages-turbo...prod.js gzip 21.7 kB 21.7 kB
pages.runtim...dev.js gzip 27.5 kB 27.5 kB
pages.runtim..prod.js gzip 21.7 kB 21.7 kB
server.runti..prod.js gzip 916 kB 916 kB N/A
Overall change 1.51 MB 1.51 MB
build cache Overall increase ⚠️
vercel/next.js canary vercel/next.js sokra/dot-slash-prefix-on-relative-paths Change
0.pack gzip 2.08 MB 2.08 MB ⚠️ +4.24 kB
index.pack gzip 74.1 kB 74.9 kB ⚠️ +735 B
Overall change 2.15 MB 2.16 MB ⚠️ +4.97 kB
Diff details
Diff for main-HASH.js

Diff too large to display

Diff for server.runtime.prod.js

Diff too large to display

Commit: 7a2261c

@sokra sokra force-pushed the sokra/fix-double-dot-slash branch from 1dcea85 to bb85aa2 Compare December 6, 2024 09:01
@sokra sokra force-pushed the sokra/dot-slash-prefix-on-relative-paths branch 2 times, most recently from 707756f to 262b7a8 Compare December 9, 2024 07:34
@ijjk ijjk added create-next-app Related to our CLI tool for quickly starting a new Next.js application. Documentation Related to Next.js' official documentation. examples Issue was opened via the examples template. Font (next/font) Related to Next.js Font Optimization. Turbopack Related to Turbopack with Next.js. labels Dec 9, 2024
@sokra sokra changed the base branch from sokra/fix-double-dot-slash to sokra/fix-monorepo-paths December 9, 2024 07:34
@sokra sokra force-pushed the sokra/fix-monorepo-paths branch from 466d6b8 to 2b7ca40 Compare December 19, 2024 08:27
@sokra sokra force-pushed the sokra/dot-slash-prefix-on-relative-paths branch 2 times, most recently from 6b0dfff to 3b548a2 Compare December 19, 2024 10:25
@sokra sokra changed the base branch from sokra/fix-monorepo-paths to graphite-base/73585 December 19, 2024 11:56
@sokra sokra force-pushed the graphite-base/73585 branch from 8e343d7 to 53bb90c Compare December 19, 2024 11:59
@sokra sokra force-pushed the sokra/dot-slash-prefix-on-relative-paths branch from 3b548a2 to f9a5997 Compare December 19, 2024 11:59
@sokra sokra changed the base branch from graphite-base/73585 to canary December 19, 2024 12:00
@sokra sokra force-pushed the sokra/dot-slash-prefix-on-relative-paths branch from f9a5997 to 7a2261c Compare December 19, 2024 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
create-next-app Related to our CLI tool for quickly starting a new Next.js application. created-by: Turbopack team PRs by the Turbopack team. Documentation Related to Next.js' official documentation. examples Issue was opened via the examples template. Font (next/font) Related to Next.js Font Optimization. tests Turbopack Related to Turbopack with Next.js. type: next
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants