Skip to content

Turbopack: trace externals imported only by server actions#95824

Merged
mischnic merged 3 commits into
canaryfrom
fix/nft-server-action-externals
Jul 16, 2026
Merged

Turbopack: trace externals imported only by server actions#95824
mischnic merged 3 commits into
canaryfrom
fix/nft-server-action-externals

Conversation

@gaearon

@gaearon gaearon commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

#95815 refactored the NFT flow and ended up only tracing the RSC template and it's subgraph. Not the server actions loader module whose module graph is completely separate.


Clauded.

Attempts to fix #95130 (reply in thread).


Details

Summary

Fixes the NFT tracing regression behind #95815 and the deploy failures reported in #87737 (comment).

Since the 16.3 NFT rewrite (#94224 / #92901), a serverExternalPackages entry that is imported only from a 'use server' action referenced by a client component ends up in the route's trace as the content-hashed alias symlink (.next/node_modules/<pkg>-<hash>) without the store files the symlink points to. Any output assembled from the traces (Vercel lambdas, output: 'standalone') then contains a dangling symlink, and invoking the action throws Failed to load external module <pkg>-<hash> (HTTP 500). 16.2.9 traces both. Both CJS and ESM externals are affected, with any package manager — the ESM/bun/monorepo framing in the issue reports was a coincidence of which packages were only reachable through actions.

The cause: AppEndpoint::trace_result started the trace DFS only from rsc_entry, but the server actions loader is a separate module-graph entry (additional_entries). It is chunked into the endpoint output (which emits the alias symlink via the chunk's output assets), yet its subgraph — including the externals' traced target files — was never visited by the tracer. trace_endpoint now accepts multiple entry modules and the app endpoint passes the actions loader alongside rsc_entry.

The test observes the user-visible failure: it builds with output: 'standalone', deletes everything except the standalone output (so only traced files are available, like a deployed lambda), runs server.js, and invokes the server action in a browser. Without the fix the action fails with Failed to load external module lodash-<hash>; on 16.2.9 the same fixture responds with the action result. Note the fixture must not import the externals from any other route: the standalone output is the union of all route traces, so a route that traces them correctly would mask the missing entries.

Verification

  • pnpm test-start-turbo test/production/standalone-mode/server-action-externals/standalone-mode-server-action-externals.test.ts — fails without the fix (Failed to load external module lodash-fb78ad0536ffcdab from the standalone server), passes with it. The equivalent standalone flow on next@16.2.9 returns the action result with HTTP 200.
  • pnpm test-start-turbo test/e2e/externals-transitive/externals-transitive.test.ts
  • pnpm test-start-turbo test/production/standalone-mode/server-actions/standalone-mode-server-actions.test.ts

@github-actions

github-actions Bot commented Jul 15, 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) 813ms 814ms ▂▁▂█▂
Cold (Ready in log) 788ms 803ms ▂▁▂█▁
Cold (First Request) 1.337s 1.354s ▂▁▃█▁
Warm (Listen) 813ms 813ms ▂▁▂█▂
Warm (Ready in log) 792ms 800ms ▁▁▂█▁
Warm (First Request) 1.325s 1.356s ▁▁▃█▁
📦 Dev Server (Webpack) (Legacy)

📦 Dev Server (Webpack)

Metric Canary PR Change Trend
Cold (Listen) 810ms 760ms ▂█▁▁▁
Cold (Ready in log) 772ms 760ms ▁█▁▁▁
Cold (First Request) 3.309s 3.312s ▁█▁▁▁
Warm (Listen) 813ms 761ms ▂█▁▂▂
Warm (Ready in log) 777ms 761ms ▁█▁▁▁
Warm (First Request) 3.340s 3.291s ▂█▁▁▁

⚡ Production Builds

Metric Canary PR Change Trend
Fresh Build 5.206s 5.466s ▃▁▄█▁
Cached Build 5.520s 5.660s ▂▁▄█▁
📦 Production Builds (Webpack) (Legacy)

📦 Production Builds (Webpack)

Metric Canary PR Change Trend
Fresh Build 24.601s 24.670s ▁█▁▁▂
Cached Build 24.759s 24.435s ▁█▁▁▁
node_modules Size 516 MB 516 MB ▁▁▁▁▁
📦 Bundle Sizes

Bundle Sizes

⚡ Turbopack

Client

Main Bundles
Canary PR Change
03gmyxr7dukvs.js gzip 10.3 kB N/A -
040t1q17lo593.js gzip 8.77 kB N/A -
0bb0vtp8dwsez.js gzip 450 B N/A -
0cz1d0mv5g_q7.js gzip 39.4 kB 39.4 kB
0k4bg7z2lyrsj.js gzip 71.2 kB N/A -
0l0sr6gau5xjn.js gzip 3.53 kB N/A -
0ldlfbv7hdzza.js gzip 160 B N/A -
0nxqz3q165m2l.js gzip 220 B N/A -
0qr-1tnb7_hg5.js gzip 5.72 kB N/A -
0uilzvklme4ea.js gzip 8.76 kB N/A -
0uzn65664f124.js gzip 156 B N/A -
0vqvm-kt134l6.js gzip 65.6 kB N/A -
0z0y83mfx-l-h.js gzip 10 kB N/A -
0zbg0xhmamash.js gzip 161 B N/A -
1_-g_r52k540c.js gzip 7.4 kB N/A -
15ok8ydf274z0.js gzip 10.6 kB N/A -
16b75yr3m1q8k.js gzip 157 B N/A -
16cqqcigykfea.js gzip 13.6 kB N/A -
17h18zxt1915l.js gzip 1.46 kB N/A -
1bwymzeil6p-e.js gzip 155 B N/A -
1elt1qium-r2m.css gzip 115 B 115 B
1fq1h7dxad4cv.js gzip 9.44 kB N/A -
1fym-adbk_69_.js gzip 13.1 kB N/A -
1g80-jfls9qyr.js gzip 13.2 kB N/A -
1gav7nfh4y8ln.js gzip 8.76 kB N/A -
1qgmqtttucnuy.js gzip 158 B N/A -
1u2yag1_mqbbf.js gzip 158 B N/A -
1wbu_gzf6e2-6.js gzip 155 B N/A -
2_kk8cchvu9o6.js gzip 154 B N/A -
20j6vlol6n2i6.js gzip 157 B N/A -
22e5kq1ljqvrb.js gzip 155 B N/A -
2rypqffktcxqh.js gzip 8.69 kB N/A -
2swp4nfexsh9k.js gzip 168 B N/A -
2uqsizxtehgqf.js gzip 8.79 kB N/A -
2vzktdqwbijqc.js gzip 8.74 kB N/A -
2wcar9zudlttv.js gzip 44.9 kB N/A -
3c244akvx_-be.js gzip 8.74 kB N/A -
3dmlemitx3ef3.js gzip 2.29 kB N/A -
3ik_0ra16q0xm.js gzip 156 B N/A -
4237vdj6eyslt.js gzip 8.7 kB N/A -
turbopack-06.._ceu.js gzip 3.85 kB N/A -
turbopack-0f..-x-3.js gzip 3.85 kB N/A -
turbopack-1j..4m7z.js gzip 3.85 kB N/A -
turbopack-2k..n460.js gzip 3.83 kB N/A -
turbopack-2s..r285.js gzip 3.86 kB N/A -
turbopack-3-..ez5n.js gzip 3.85 kB N/A -
turbopack-3-..3d8z.js gzip 3.85 kB N/A -
turbopack-38..l1l6.js gzip 3.85 kB N/A -
turbopack-3g..uwpl.js gzip 3.85 kB N/A -
turbopack-3i..35pn.js gzip 3.85 kB N/A -
turbopack-3i..eyi8.js gzip 3.85 kB N/A -
turbopack-3p..jk44.js gzip 3.85 kB N/A -
turbopack-3q..dnr2.js gzip 3.85 kB N/A -
turbopack-3r..y_-5.js gzip 3.85 kB N/A -
00tc16j5-eos9.js gzip N/A 1.46 kB -
043nf81t7buaf.js gzip N/A 157 B -
0a7_lcs0rt4ea.js gzip N/A 71.2 kB -
0av7uk7dyhbqs.js gzip N/A 65.6 kB -
0erhoghr_r85x.js gzip N/A 155 B -
0gaw1gmpwuwkn.js gzip N/A 8.8 kB -
0z50qk3nhbdq6.js gzip N/A 157 B -
12zyjjmq4oad1.js gzip N/A 5.72 kB -
17viiokr8i37p.js gzip N/A 160 B -
1dkyf626et1pt.js gzip N/A 155 B -
1k9cc4-gpa2cx.js gzip N/A 13.1 kB -
1n59uogejo81s.js gzip N/A 10.3 kB -
1n5xsl058uas8.js gzip N/A 156 B -
1npei3hlexdv3.js gzip N/A 9.99 kB -
1rafe6xn_-rjn.js gzip N/A 169 B -
1ssuiwj_rnpc5.js gzip N/A 8.77 kB -
1wnvw-0jq89aj.js gzip N/A 160 B -
2-phc9obd3nyd.js gzip N/A 8.77 kB -
21tr06sv6r2aa.js gzip N/A 155 B -
24utq57r3l1cw.js gzip N/A 8.7 kB -
29wx3qw2zco54.js gzip N/A 153 B -
2fhjq6ek3srmr.js gzip N/A 8.69 kB -
2g0t7upz_v-hf.js gzip N/A 10.6 kB -
2ia9qqy99aie9.js gzip N/A 13.6 kB -
2n5fp99a5xt9s.js gzip N/A 7.4 kB -
2oza28kdqvoay.js gzip N/A 8.74 kB -
2t0tdi1im2rn9.js gzip N/A 155 B -
2y610aw5qmz9t.js gzip N/A 155 B -
2zh8-mmhujy8o.js gzip N/A 2.29 kB -
30h_m0irj-q6p.js gzip N/A 221 B -
37ejbfx1u9lpo.js gzip N/A 8.75 kB -
38c63ct4i1cy7.js gzip N/A 449 B -
3hd1us4ordyc9.js gzip N/A 13.2 kB -
3ie_w4n_n95-v.js gzip N/A 155 B -
3jimpal3lvz5e.js gzip N/A 9.44 kB -
3rxda-enqm36a.js gzip N/A 45 kB -
3su6a4l8jbfth.js gzip N/A 3.53 kB -
3wb4pe4z4-aim.js gzip N/A 8.77 kB -
turbopack-0_..a57d.js gzip N/A 3.85 kB -
turbopack-02..tn05.js gzip N/A 3.85 kB -
turbopack-04..v6lm.js gzip N/A 3.83 kB -
turbopack-17..4j95.js gzip N/A 3.85 kB -
turbopack-1a..d08_.js gzip N/A 3.85 kB -
turbopack-2d..jiau.js gzip N/A 3.85 kB -
turbopack-2l..oqoo.js gzip N/A 3.85 kB -
turbopack-2s..h2sz.js gzip N/A 3.85 kB -
turbopack-3_..88bf.js gzip N/A 3.85 kB -
turbopack-3-..c140.js gzip N/A 3.85 kB -
turbopack-34..vpfu.js gzip N/A 3.86 kB -
turbopack-3g..wvqb.js gzip N/A 3.85 kB -
turbopack-3i..rskn.js gzip N/A 3.85 kB -
turbopack-3q..mn0m.js gzip N/A 3.84 kB -
Total 448 kB 448 kB ⚠️ +24 B

Server

Middleware
Canary PR Change
middleware-b..fest.js gzip 731 B 726 B
Total 731 B 726 B ✅ -5 B
Build Details
Build Manifests
Canary PR Change
_buildManifest.js gzip 433 B 432 B
Total 433 B 432 B ✅ -1 B

📦 Webpack

Client

Main Bundles
Canary PR Change
2486.HASH.js gzip 169 B N/A -
3146-HASH.js gzip 64.1 kB N/A -
39fcf99b-HASH.js gzip 62.9 kB N/A -
8443-HASH.js gzip 4.68 kB N/A -
9431-HASH.js gzip 5.62 kB N/A -
framework-HASH.js gzip 59.8 kB 59.8 kB
main-app-HASH.js gzip 255 B 252 B 🟢 3 B (-1%)
main-HASH.js gzip 39.7 kB 40.1 kB 🔴 +453 B (+1%)
webpack-HASH.js gzip 1.68 kB 1.68 kB
6105-HASH.js gzip N/A 5.63 kB -
764.HASH.js gzip N/A 169 B -
8898-HASH.js gzip N/A 63.5 kB -
9597-HASH.js gzip N/A 4.65 kB -
e1ccab69-HASH.js gzip N/A 62.9 kB -
Total 239 kB 239 kB ✅ -194 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 182 B
css-HASH.js gzip 335 B 335 B
dynamic-HASH.js gzip 1.8 kB 1.8 kB
edge-ssr-HASH.js gzip 255 B 254 B
head-HASH.js gzip 351 B 349 B
hooks-HASH.js gzip 384 B 384 B
image-HASH.js gzip 580 B 580 B
index-HASH.js gzip 259 B 259 B
link-HASH.js gzip 2.49 kB 2.49 kB
routerDirect..HASH.js gzip 319 B 319 B
script-HASH.js gzip 386 B 386 B
withRouter-HASH.js gzip 315 B 313 B
1afbb74e6ecf..834.css gzip 106 B 106 B
Total 7.96 kB 7.95 kB ✅ -7 B

Server

Edge SSR
Canary PR Change
edge-ssr.js gzip 128 kB 128 kB
page.js gzip 283 kB 285 kB
Total 410 kB 412 kB ⚠️ +2.3 kB
Middleware
Canary PR Change
middleware-b..fest.js gzip 617 B 617 B
middleware-r..fest.js gzip 156 B 155 B
middleware.js gzip 45.4 kB 45.2 kB
edge-runtime..pack.js gzip 842 B 842 B
Total 47 kB 46.8 kB ✅ -214 B
Build Details
Build Manifests
Canary PR Change
_buildManifest.js gzip 719 B 720 B
Total 719 B 720 B ⚠️ +1 B
Build Cache
Canary PR Change
0.pack gzip 4.79 MB 4.78 MB 🟢 7.66 kB (0%)
index.pack gzip 119 kB 118 kB
index.pack.old gzip 119 kB 119 kB
Total 5.02 MB 5.02 MB ✅ -8.46 kB

🔄 Shared (bundler-independent)

Runtimes
Canary PR Change
app-page-exp...dev.js gzip 363 kB 363 kB
app-page-exp..prod.js gzip 201 kB 201 kB
app-page-tur...dev.js gzip 363 kB 363 kB
app-page-tur..prod.js gzip 201 kB 201 kB
app-page-tur...dev.js gzip 360 kB 360 kB
app-page-tur..prod.js gzip 199 kB 199 kB
app-page.run...dev.js gzip 360 kB 360 kB
app-page.run..prod.js gzip 199 kB 199 kB
app-route-ex...dev.js gzip 81.3 kB 81.3 kB
app-route-ex..prod.js gzip 55.3 kB 55.3 kB
app-route-tu...dev.js gzip 81.4 kB 81.4 kB
app-route-tu..prod.js gzip 55.4 kB 55.4 kB
app-route-tu...dev.js gzip 81 kB 81 kB
app-route-tu..prod.js gzip 55.1 kB 55.1 kB
app-route.ru...dev.js gzip 80.9 kB 80.9 kB
app-route.ru..prod.js gzip 55.1 kB 55.1 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 45.2 kB 45.2 kB
pages-api-tu..prod.js gzip 34 kB 34 kB
pages-api.ru...dev.js gzip 45.2 kB 45.2 kB
pages-api.ru..prod.js gzip 33.9 kB 33.9 kB
pages-turbo....dev.js gzip 54.7 kB 54.7 kB
pages-turbo...prod.js gzip 39.6 kB 39.6 kB
pages.runtim...dev.js gzip 54.7 kB 54.7 kB
pages.runtim..prod.js gzip 39.6 kB 39.6 kB
server.runti..prod.js gzip 65.3 kB 65.3 kB
use-cache-pr...dev.js gzip 71.4 kB 71.4 kB
use-cache-pr...dev.js gzip 71.4 kB 71.4 kB
use-cache-pr...dev.js gzip 69.7 kB 69.7 kB
use-cache-pr...dev.js gzip 69.7 kB 69.7 kB
Total 3.49 MB 3.49 MB
📎 Tarball URL
https://vercel-packages.vercel.app/next/commits/8faa9c35724849457deedd51e001f35305562d96/next

Commit: 8faa9c3

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Tests Passed

Commit: 8faa9c3

@gaearon gaearon changed the title Add failing test for NFT tracing of server-action-only externals Add failing test for server action externals in standalone mode Jul 15, 2026
@gaearon gaearon changed the title Add failing test for server action externals in standalone mode Turbopack: trace externals imported only by server actions Jul 15, 2026
@mischnic
mischnic marked this pull request as ready for review July 16, 2026 05:10

@mischnic mischnic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thankfully these annoying additional_entries will be removed soon anyway.

@mischnic
mischnic merged commit b7ab553 into canary Jul 16, 2026
228 of 230 checks passed
@mischnic
mischnic deleted the fix/nft-server-action-externals branch July 16, 2026 05:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants