Skip to content

mark connection as invalid api in client component - #89288

Closed
huozhi wants to merge 2 commits into
canaryfrom
invalid-connection-api
Closed

mark connection as invalid api in client component#89288
huozhi wants to merge 2 commits into
canaryfrom
invalid-connection-api

Conversation

@huozhi

@huozhi huozhi commented Jan 30, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@nextjs-bot nextjs-bot added created-by: Next.js team PRs by the Next.js team. tests Turbopack Related to Turbopack with Next.js. labels Jan 30, 2026
@nextjs-bot

nextjs-bot commented Jan 30, 2026

Copy link
Copy Markdown
Contributor

Failing test suites

Commit: d3a3de5 | About building and testing Next.js

pnpm test-dev test/development/app-dir/next-server-invalid-api/index.test.ts (job)

  • next/server APIs in client components > errors at compile time when after() is used in a client module (DD)
  • next/server APIs in client components > errors at compile time when connection() is used in a client module (DD)
Expand output

● next/server APIs in client components › errors at compile time when after() is used in a client module

expect(received).toMatchInlineSnapshot(snapshot)

Snapshot name: `next/server APIs in client components errors at compile time when after() is used in a client module 1`

- Snapshot  - 21
+ Received  + 17

- "./app/invalid-after/page.js (3:10)
- Ecmascript file had an error
-   1 | 'use client'
-   2 |
- > 3 | import { after } from 'next/server'
-     |          ^^^^^
-   4 |
-   5 | export default function Page() {
-   6 |   after(() => {})
-
- You're importing a component that needs "after". That only works in a Server Component but one of its parents is marked with "use client", so it's a Client Component.
+ "./app/invalid-after/page.js
+ Error:   x You're importing a component that needs "after". That only works in a Server Component but one of its parents is marked with "use client", so it's a Client Component.
- Learn more: https://nextjs.org/docs/app/building-your-application/rendering
+   | Learn more: https://nextjs.org/docs/app/building-your-application/rendering
-
- Import traces:
-   Client Component Browser:
-     ./app/invalid-after/page.js [Client Component Browser]
-     ./app/invalid-after/page.js [Server Component]
-
-   Client Component SSR:
-     ./app/invalid-after/page.js [Client Component SSR]
-     ./app/invalid-after/page.js [Server Component]"
+   |
+
+    ,-[3:1]
+  1 | 'use client'
+  2 | 
+  3 | import { after } from 'next/server'
+    :          ^^^^^
+  4 | 
+  5 | export default function Page() {
+  6 |   after(() => {})
+    `----
+
+ Import trace for requested module:
+ ./app/invalid-after/page.js"

  25 |
  26 |     await retry(async () => {
> 27 |       expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
     |                                               ^
  28 |        "./app/invalid-after/page.js (3:10)
  29 |        Ecmascript file had an error
  30 |          1 | 'use client'

  at toMatchInlineSnapshot (development/app-dir/next-server-invalid-api/index.test.ts:27:47)
  at retry (lib/next-test-utils.ts:831:14)
  at Object.<anonymous> (development/app-dir/next-server-invalid-api/index.test.ts:26:5)

● next/server APIs in client components › errors at compile time when connection() is used in a client module

expect(received).toMatchInlineSnapshot(snapshot)

Snapshot name: `next/server APIs in client components errors at compile time when connection() is used in a client module 1`

- Snapshot  - 21
+ Received  + 17

- "./app/invalid-connection/page.js (3:10)
- Ecmascript file had an error
-   1 | 'use client'
-   2 |
- > 3 | import { connection } from 'next/server'
-     |          ^^^^^^^^^^
-   4 |
-   5 | export default function Page() {
-   6 |   connection()
-
- You're importing a component that needs "connection". That only works in a Server Component but one of its parents is marked with "use client", so it's a Client Component.
+ "./app/invalid-connection/page.js
+ Error:   x You're importing a component that needs "connection". That only works in a Server Component but one of its parents is marked with "use client", so it's a Client Component.
- Learn more: https://nextjs.org/docs/app/building-your-application/rendering
+   | Learn more: https://nextjs.org/docs/app/building-your-application/rendering
-
- Import traces:
-   Client Component Browser:
-     ./app/invalid-connection/page.js [Client Component Browser]
-     ./app/invalid-connection/page.js [Server Component]
-
-   Client Component SSR:
-     ./app/invalid-connection/page.js [Client Component SSR]
-     ./app/invalid-connection/page.js [Server Component]"
+   |
+
+    ,-[3:1]
+  1 | 'use client'
+  2 | 
+  3 | import { connection } from 'next/server'
+    :          ^^^^^^^^^^
+  4 | 
+  5 | export default function Page() {
+  6 |   connection()
+    `----
+
+ Import trace for requested module:
+ ./app/invalid-connection/page.js"

  71 |
  72 |     await retry(async () => {
> 73 |       expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
     |                                               ^
  74 |        "./app/invalid-connection/page.js (3:10)
  75 |        Ecmascript file had an error
  76 |          1 | 'use client'

  at toMatchInlineSnapshot (development/app-dir/next-server-invalid-api/index.test.ts:73:47)
  at retry (lib/next-test-utils.ts:831:14)
  at Object.<anonymous> (development/app-dir/next-server-invalid-api/index.test.ts:72:5)

pnpm test-start-turbo test/e2e/on-request-error/skip-next-internal-error/skip-next-internal-error.test.ts (turbopack) (job)

  • on-request-error - skip-next-internal-error > app router API > should not catch server component not-found errors (DD)
  • on-request-error - skip-next-internal-error > app router API > should not catch server component redirect errors (DD)
  • on-request-error - skip-next-internal-error > app router render > should not catch server component not-found errors (DD)
  • on-request-error - skip-next-internal-error > app router render > should not catch server component redirect errors (DD)
  • on-request-error - skip-next-internal-error > app router render > should not catch client component not-found errors (DD)
  • on-request-error - skip-next-internal-error > app router render > should not catch client component redirect errors (DD)
  • on-request-error - skip-next-internal-error > app router render > should not catch server component dynamic usage errors (DD)
  • on-request-error - skip-next-internal-error > app router render > should not catch client component dynamic usage errors (DD)
  • on-request-error - skip-next-internal-error > app router render > should not catch next dynamic no-ssr errors (DD)
  • on-request-error - skip-next-internal-error > app router render > should not catch server action not-found errors (DD)
  • on-request-error - skip-next-internal-error > app router render > should not catch server action redirect errors (DD)
Expand output

● on-request-error - skip-next-internal-error › app router render › should not catch server component not-found errors

next build failed with code/signal 1

  77 |             if (code || signal)
  78 |               reject(
> 79 |                 new Error(
     |                 ^
  80 |                   `next build failed with code/signal ${code || signal}`
  81 |                 )
  82 |               )

  at ChildProcess.<anonymous> (lib/next-modes/next-start.ts:79:17)

● on-request-error - skip-next-internal-error › app router render › should not catch server component redirect errors

next build failed with code/signal 1

  77 |             if (code || signal)
  78 |               reject(
> 79 |                 new Error(
     |                 ^
  80 |                   `next build failed with code/signal ${code || signal}`
  81 |                 )
  82 |               )

  at ChildProcess.<anonymous> (lib/next-modes/next-start.ts:79:17)

● on-request-error - skip-next-internal-error › app router render › should not catch client component not-found errors

next build failed with code/signal 1

  77 |             if (code || signal)
  78 |               reject(
> 79 |                 new Error(
     |                 ^
  80 |                   `next build failed with code/signal ${code || signal}`
  81 |                 )
  82 |               )

  at ChildProcess.<anonymous> (lib/next-modes/next-start.ts:79:17)

● on-request-error - skip-next-internal-error › app router render › should not catch client component redirect errors

next build failed with code/signal 1

  77 |             if (code || signal)
  78 |               reject(
> 79 |                 new Error(
     |                 ^
  80 |                   `next build failed with code/signal ${code || signal}`
  81 |                 )
  82 |               )

  at ChildProcess.<anonymous> (lib/next-modes/next-start.ts:79:17)

● on-request-error - skip-next-internal-error › app router render › should not catch server component dynamic usage errors

next build failed with code/signal 1

  77 |             if (code || signal)
  78 |               reject(
> 79 |                 new Error(
     |                 ^
  80 |                   `next build failed with code/signal ${code || signal}`
  81 |                 )
  82 |               )

  at ChildProcess.<anonymous> (lib/next-modes/next-start.ts:79:17)

● on-request-error - skip-next-internal-error › app router render › should not catch client component dynamic usage errors

next build failed with code/signal 1

  77 |             if (code || signal)
  78 |               reject(
> 79 |                 new Error(
     |                 ^
  80 |                   `next build failed with code/signal ${code || signal}`
  81 |                 )
  82 |               )

  at ChildProcess.<anonymous> (lib/next-modes/next-start.ts:79:17)

● on-request-error - skip-next-internal-error › app router render › should not catch next dynamic no-ssr errors

next build failed with code/signal 1

  77 |             if (code || signal)
  78 |               reject(
> 79 |                 new Error(
     |                 ^
  80 |                   `next build failed with code/signal ${code || signal}`
  81 |                 )
  82 |               )

  at ChildProcess.<anonymous> (lib/next-modes/next-start.ts:79:17)

● on-request-error - skip-next-internal-error › app router render › should not catch server action not-found errors

next build failed with code/signal 1

  77 |             if (code || signal)
  78 |               reject(
> 79 |                 new Error(
     |                 ^
  80 |                   `next build failed with code/signal ${code || signal}`
  81 |                 )
  82 |               )

  at ChildProcess.<anonymous> (lib/next-modes/next-start.ts:79:17)

● on-request-error - skip-next-internal-error › app router render › should not catch server action redirect errors

next build failed with code/signal 1

  77 |             if (code || signal)
  78 |               reject(
> 79 |                 new Error(
     |                 ^
  80 |                   `next build failed with code/signal ${code || signal}`
  81 |                 )
  82 |               )

  at ChildProcess.<anonymous> (lib/next-modes/next-start.ts:79:17)

● on-request-error - skip-next-internal-error › app router API › should not catch server component not-found errors

next build failed with code/signal 1

  77 |             if (code || signal)
  78 |               reject(
> 79 |                 new Error(
     |                 ^
  80 |                   `next build failed with code/signal ${code || signal}`
  81 |                 )
  82 |               )

  at ChildProcess.<anonymous> (lib/next-modes/next-start.ts:79:17)

● on-request-error - skip-next-internal-error › app router API › should not catch server component redirect errors

next build failed with code/signal 1

  77 |             if (code || signal)
  78 |               reject(
> 79 |                 new Error(
     |                 ^
  80 |                   `next build failed with code/signal ${code || signal}`
  81 |                 )
  82 |               )

  at ChildProcess.<anonymous> (lib/next-modes/next-start.ts:79:17)

pnpm test-start-turbo test/e2e/app-dir/app-client-cache/client-cache.parallel-routes.test.ts (turbopack) (job)

  • app dir client cache with parallel routes > prefetch={true} > should re-use the cache for the full page, only for 5 mins (DD)
Expand output

● app dir client cache with parallel routes › prefetch={true} › should re-use the cache for the full page, only for 5 mins

thrown: "Exceeded timeout of 120000 ms for a test.
Add a timeout value to this test to increase the timeout, if this is a long-running test. See https://jestjs.io/docs/api#testname-fn-timeout."

  54 |     })
  55 |
> 56 |     it('should re-use the cache for the full page, only for 5 mins', async () => {
     |     ^
  57 |       let page: PlaywrightPage
  58 |       const browser = await next.browser('/', {
  59 |         async beforePageLoad(p) {

  at it (e2e/app-dir/app-client-cache/client-cache.parallel-routes.test.ts:56:5)
  at describe (e2e/app-dir/app-client-cache/client-cache.parallel-routes.test.ts:30:3)
  at Object.describe (e2e/app-dir/app-client-cache/client-cache.parallel-routes.test.ts:7:1)

pnpm test-start-turbo test/e2e/app-dir/worker/worker.test.ts (turbopack) (job)

Expand output

● Test suite failed to run

Jest encountered an unexpected token

Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

By default "node_modules" folder is ignored by transformers.

Here's what you can do:
 • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.
 • If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
 • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
 • If you need a custom transformation specify a "transform" option in your config.
 • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/configuration
For information about custom transformations, see:
https://jestjs.io/docs/code-transformation

Details:

/root/actions-runner/_work/next.js/next.js/test/e2e/app-dir/worker/worker.test.ts:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import { nextTestSetup } from 'e2e-utils';
                                                                                  ^^^^^^

SyntaxError: Cannot use import statement outside a module

  at Runtime.createScriptFromCode (../node_modules/.pnpm/jest-runtime@29.7.0/node_modules/jest-runtime/build/index.js:1505:14)

@nextjs-bot

nextjs-bot commented Jan 30, 2026

Copy link
Copy Markdown
Contributor

Stats from current PR

✅ No significant changes detected

📊 All Metrics
📖 Metrics Glossary

Dev Server Metrics:

  • Listen = TCP port starts accepting connections
  • First Request = HTTP server returns successful response
  • Cold = Fresh build (no cache)
  • Warm = With cached build artifacts

Build Metrics:

  • Fresh = Clean build (no .next directory)
  • Cached = With existing .next directory

Change Thresholds:

  • Time: Changes < 50ms AND < 10%, OR < 2% are insignificant
  • Size: Changes < 1KB AND < 1% are insignificant
  • All other changes are flagged to catch regressions

⚡ Dev Server

Metric Canary PR Change Trend
Cold (Listen) 455ms 455ms ▁▁▁▁▁
Cold (Ready in log) 435ms 435ms ▇▆▇█▁
Cold (First Request) 1.185s 1.157s ▇▆▇█▁
Warm (Listen) 456ms 456ms ▁▁▁▁▁
Warm (Ready in log) 439ms 444ms ▁▁▁▂▃
Warm (First Request) 336ms 332ms ▆▁▁▅▄
📦 Dev Server (Webpack) (Legacy)

📦 Dev Server (Webpack)

Metric Canary PR Change Trend
Cold (Listen) 456ms 454ms ▁▁▁▁▁
Cold (Ready in log) 435ms 436ms ▆▄▅▅▅
Cold (First Request) 1.772s 1.754s ▅▃▃▃▄
Warm (Listen) 456ms 456ms ▁▁▁▁▁
Warm (Ready in log) 434ms 434ms ▅▅▆▅▆
Warm (First Request) 1.759s 1.780s ▅▃▃▃▄

⚡ Production Builds

Metric Canary PR Change Trend
Fresh Build 3.898s 3.868s ▂▁▂▂▅
Cached Build 3.902s 3.928s ▂▁▂▂█
📦 Production Builds (Webpack) (Legacy)

📦 Production Builds (Webpack)

Metric Canary PR Change Trend
Fresh Build 13.658s 13.612s ▅▁▁▂▂
Cached Build 13.707s 13.696s ▅▁▁▁▂
node_modules Size 464 MB 464 MB ▁▁▁▁▁
📦 Bundle Sizes

Bundle Sizes

⚡ Turbopack

Client

Main Bundles: **435 kB** → **435 kB** ✓

81 files with content-based hashes (individual files not comparable between builds)

Server

Middleware
Canary PR Change
middleware-b..fest.js gzip 760 B 764 B
Total 760 B 764 B ⚠️ +4 B
Build Details
Build Manifests
Canary PR Change
_buildManifest.js gzip 447 B 450 B
Total 447 B 450 B ⚠️ +3 B

📦 Webpack

Client

Main Bundles
Canary PR Change
5528-HASH.js gzip 5.47 kB N/A -
6280-HASH.js gzip 54.6 kB N/A -
6335.HASH.js gzip 169 B N/A -
912-HASH.js gzip 4.53 kB N/A -
e8aec2e4-HASH.js gzip 62.5 kB N/A -
framework-HASH.js gzip 59.7 kB 59.7 kB
main-app-HASH.js gzip 255 B 252 B 🟢 3 B (-1%)
main-HASH.js gzip 39 kB 39 kB
webpack-HASH.js gzip 1.68 kB 1.68 kB
262-HASH.js gzip N/A 4.52 kB -
2889.HASH.js gzip N/A 169 B -
5602-HASH.js gzip N/A 5.48 kB -
6948ada0-HASH.js gzip N/A 62.5 kB -
9544-HASH.js gzip N/A 55.3 kB -
Total 228 kB 229 kB ⚠️ +680 B
Polyfills
Canary PR Change
polyfills-HASH.js gzip 39.4 kB 39.4 kB
Total 39.4 kB 39.4 kB
Pages
Canary PR Change
_app-HASH.js gzip 194 B 194 B
_error-HASH.js gzip 183 B 180 B 🟢 3 B (-2%)
css-HASH.js gzip 331 B 330 B
dynamic-HASH.js gzip 1.81 kB 1.81 kB
edge-ssr-HASH.js gzip 256 B 256 B
head-HASH.js gzip 351 B 352 B
hooks-HASH.js gzip 384 B 383 B
image-HASH.js gzip 580 B 581 B
index-HASH.js gzip 260 B 260 B
link-HASH.js gzip 2.49 kB 2.49 kB
routerDirect..HASH.js gzip 320 B 319 B
script-HASH.js gzip 386 B 386 B
withRouter-HASH.js gzip 315 B 315 B
1afbb74e6ecf..834.css gzip 106 B 106 B
Total 7.97 kB 7.97 kB ✅ -1 B

Server

Edge SSR
Canary PR Change
edge-ssr.js gzip 126 kB 126 kB
page.js gzip 249 kB 249 kB
Total 375 kB 375 kB ⚠️ +144 B
Middleware
Canary PR Change
middleware-b..fest.js gzip 615 B 614 B
middleware-r..fest.js gzip 156 B 155 B
middleware.js gzip 33 kB 33.2 kB
edge-runtime..pack.js gzip 842 B 842 B
Total 34.6 kB 34.8 kB ⚠️ +263 B
Build Details
Build Manifests
Canary PR Change
_buildManifest.js gzip 732 B 736 B
Total 732 B 736 B ⚠️ +4 B
Build Cache
Canary PR Change
0.pack gzip 3.8 MB 3.8 MB 🔴 +4.67 kB (+0%)
index.pack gzip 103 kB 103 kB
index.pack.old gzip 101 kB 103 kB 🔴 +1.92 kB (+2%)
Total 4 MB 4.01 MB ⚠️ +6.49 kB

🔄 Shared (bundler-independent)

Runtimes
Canary PR Change
app-page-exp...dev.js gzip 311 kB 311 kB
app-page-exp..prod.js gzip 166 kB 166 kB
app-page-tur...dev.js gzip 311 kB 311 kB
app-page-tur..prod.js gzip 166 kB 166 kB
app-page-tur...dev.js gzip 308 kB 308 kB
app-page-tur..prod.js gzip 164 kB 164 kB
app-page.run...dev.js gzip 308 kB 308 kB
app-page.run..prod.js gzip 164 kB 164 kB
app-route-ex...dev.js gzip 70.4 kB 70.4 kB
app-route-ex..prod.js gzip 48.9 kB 48.9 kB
app-route-tu...dev.js gzip 70.4 kB 70.4 kB
app-route-tu..prod.js gzip 48.9 kB 48.9 kB
app-route-tu...dev.js gzip 70 kB 70 kB
app-route-tu..prod.js gzip 48.7 kB 48.7 kB
app-route.ru...dev.js gzip 69.9 kB 69.9 kB
app-route.ru..prod.js gzip 48.7 kB 48.7 kB
dist_client_...dev.js gzip 324 B 324 B
dist_client_...dev.js gzip 326 B 326 B
dist_client_...dev.js gzip 318 B 318 B
dist_client_...dev.js gzip 317 B 317 B
pages-api-tu...dev.js gzip 43.1 kB 43.1 kB
pages-api-tu..prod.js gzip 32.8 kB 32.8 kB
pages-api.ru...dev.js gzip 43.1 kB 43.1 kB
pages-api.ru..prod.js gzip 32.8 kB 32.8 kB
pages-turbo....dev.js gzip 52.4 kB 52.4 kB
pages-turbo...prod.js gzip 39.3 kB 39.3 kB
pages.runtim...dev.js gzip 52.3 kB 52.3 kB
pages.runtim..prod.js gzip 39.3 kB 39.3 kB
server.runti..prod.js gzip 62.5 kB 62.5 kB
Total 2.77 MB 2.77 MB ⚠️ +2 B

@codspeed-hq

codspeed-hq Bot commented Jan 30, 2026

Copy link
Copy Markdown

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing invalid-connection-api (d3a3de5) with canary (af18c32)

Summary

✅ 17 untouched benchmarks
⏩ 3 skipped benchmarks1

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@huozhi
huozhi force-pushed the invalid-connection-api branch from 20efd73 to 0f5b754 Compare January 30, 2026 14:31
@huozhi
huozhi force-pushed the invalid-connection-api branch from 0f5b754 to 84611f9 Compare January 30, 2026 15:17
@huozhi huozhi closed this Feb 24, 2026
@huozhi
huozhi deleted the invalid-connection-api branch February 24, 2026 13:27
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Mar 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

created-by: Next.js team PRs by the Next.js team. locked tests Turbopack Related to Turbopack with Next.js.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants