Skip to content

Expose a new napi binding for accessing the source map _path_ of a source asset#95942

Draft
lukesandberg wants to merge 3 commits into
canaryfrom
lukesandberg/get_source_map_url_sync
Draft

Expose a new napi binding for accessing the source map _path_ of a source asset#95942
lukesandberg wants to merge 3 commits into
canaryfrom
lukesandberg/get_source_map_url_sync

Conversation

@lukesandberg

@lukesandberg lukesandberg commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Add a new synchronous napi endpoint for computing the sourcemap filename from a source in dev

This can be used by findSourceMapURLDEV to create a more efficient solution in the future

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Failing test suites

Commit: 1519927 | About building and testing Next.js

pnpm test-dev test/development/acceptance-app/rsc-build-errors-poisoned-imports.test.ts (job)

  • Error overlay - RSC build errors > should error when catchError from next/error is imported in proxy.js (DD)
Expand output

● Error overlay - RSC build errors › should error when catchError from next/error is imported in proxy.js

Expected Redbox but found no visible one.

  124 |
  125 |       const { session } = sandbox
> 126 |       await session.waitForRedbox()
      |       ^
  127 |       expect(await session.getRedboxSource()).toInclude(
  128 |         'You\'re importing a module that depends on `catchError` into a React Server Component module. This API is only available in Client Components. To fix, mark the file (or its parent) with the `"use client"` directive.'
  129 |       )

  at development/acceptance-app/rsc-build-errors-poisoned-imports.test.ts:126:7

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Stats from current PR

🔴 5 regressions, 1 improvement

Metric Canary PR Change Trend
Turbo Build Time 5.281s 5.549s 🔴 +268ms (+5%) ▁▂▁▂▁
Turbo Build Time (cached) 5.364s 5.725s 🔴 +361ms (+7%) ▁▂▁▁▁
Webpack Build Time 25.098s 26.680s 🔴 +1.582s (+6%) ▂▁▂▂█
Webpack Build Time (cached) 25.241s 25.971s 🔴 +730ms (+3%) ▂▁▂▂█
Webpack Cold (First Request) 3.379s 4.316s 🔴 +937ms (+28%) ▂▁▂▃█
Webpack Warm (First Request) 3.574s 3.419s 🟢 155ms (-4%) ▂▁▂▃█
📊 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) 789ms 805ms ▁▂▁▁▁
Cold (First Request) 1.332s 1.375s ▁▁▁▁▁
Warm (Listen) 813ms 813ms ▂▂▁▁▁
Warm (Ready in log) 798ms 796ms ▁▁▁▁▁
Warm (First Request) 1.344s 1.354s ▁▁▁▂▁
📦 Dev Server (Webpack) (Legacy)

📦 Dev Server (Webpack)

Metric Canary PR Change Trend
Cold (Listen) 812ms 813ms ▂▁▂▂█
Cold (Ready in log) 772ms 781ms ▂▁▁▃█
Cold (First Request) 3.379s 4.316s 🔴 +937ms (+28%) ▂▁▂▃█
Warm (Listen) 814ms 813ms ▂▁▂▂█
Warm (Ready in log) 798ms 788ms ▂▁▂▂█
Warm (First Request) 3.574s 3.419s 🟢 155ms (-4%) ▂▁▂▃█

⚡ Production Builds

Metric Canary PR Change Trend
Fresh Build 5.281s 5.549s 🔴 +268ms (+5%) ▁▂▁▂▁
Cached Build 5.364s 5.725s 🔴 +361ms (+7%) ▁▂▁▁▁
📦 Production Builds (Webpack) (Legacy)

📦 Production Builds (Webpack)

Metric Canary PR Change Trend
Fresh Build 25.098s 26.680s 🔴 +1.582s (+6%) ▂▁▂▂█
Cached Build 25.241s 25.971s 🔴 +730ms (+3%) ▂▁▂▂█
node_modules Size 517 MB 517 MB ▁▁▁▁█
📦 Bundle Sizes

Bundle Sizes

⚡ Turbopack

Client

Main Bundles
Canary PR Change
0273j2-i6qkw4.js gzip 162 B N/A -
02frxk4kfgzv_.js gzip 155 B N/A -
03gmyxr7dukvs.js gzip 10.3 kB N/A -
040t1q17lo593.js gzip 8.77 kB N/A -
05m2nb2_o-jlv.js gzip 155 B N/A -
0bb0vtp8dwsez.js gzip 450 B N/A -
0cz1d0mv5g_q7.js gzip 39.4 kB 39.4 kB
0kqq9k7djlyvz.js gzip 157 B N/A -
0l0sr6gau5xjn.js gzip 3.53 kB N/A -
0nxqz3q165m2l.js gzip 220 B N/A -
0on5bfg96uqxk.js gzip 65.6 kB N/A -
0p1r-feajb5jb.js gzip 71 kB N/A -
0qr-1tnb7_hg5.js gzip 5.72 kB N/A -
0uilzvklme4ea.js gzip 8.76 kB N/A -
0xiw1unpygi1c.js gzip 157 B N/A -
0xyuy39dq2pzd.js gzip 156 B N/A -
0z0y83mfx-l-h.js gzip 10 kB N/A -
14ff853ktwa9b.js gzip 154 B N/A -
15ok8ydf274z0.js gzip 10.6 kB N/A -
16cqqcigykfea.js gzip 13.6 kB N/A -
17h18zxt1915l.js gzip 1.46 kB N/A -
1bs04l2ed4r7a.js gzip 153 B N/A -
1bxtbnlhloeph.js gzip 169 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 -
1gav7nfh4y8ln.js gzip 8.76 kB N/A -
1o34vh44ndvtu.js gzip 13.2 kB N/A -
1r4p-e_k9ckke.js gzip 157 B N/A -
27kmxbcd9zzhi.js gzip 160 B N/A -
2lpy00b303z50.js gzip 158 B N/A -
2rypqffktcxqh.js gzip 8.69 kB N/A -
2uqsizxtehgqf.js gzip 8.79 kB N/A -
2vzktdqwbijqc.js gzip 8.74 kB N/A -
3bhf_ndbc3iz2.js gzip 158 B N/A -
3c244akvx_-be.js gzip 8.74 kB N/A -
3dmlemitx3ef3.js gzip 2.29 kB N/A -
3lk7xgw97hbb3.js gzip 7.4 kB N/A -
3vfl1fxa4me-g.js gzip 45.2 kB N/A -
4237vdj6eyslt.js gzip 8.7 kB N/A -
turbopack-01..-1_6.js gzip 3.8 kB N/A -
turbopack-0j..iuww.js gzip 3.8 kB N/A -
turbopack-13..am56.js gzip 3.8 kB N/A -
turbopack-13..4w7t.js gzip 3.82 kB N/A -
turbopack-15..1saa.js gzip 3.81 kB N/A -
turbopack-1f..n2-o.js gzip 3.79 kB N/A -
turbopack-24..w6pd.js gzip 3.8 kB N/A -
turbopack-2l..18oa.js gzip 3.8 kB N/A -
turbopack-2p..qm-4.js gzip 3.8 kB N/A -
turbopack-2x..9yw0.js gzip 3.8 kB N/A -
turbopack-36..z3of.js gzip 3.81 kB N/A -
turbopack-3f..htxq.js gzip 3.8 kB N/A -
turbopack-3p..qki7.js gzip 3.8 kB N/A -
turbopack-43..nmng.js gzip 3.8 kB N/A -
00tc16j5-eos9.js gzip N/A 1.46 kB -
02jud9pe218fc.js gzip N/A 7.4 kB -
0gaw1gmpwuwkn.js gzip N/A 8.8 kB -
1-oaf1uo7f5x3.js gzip N/A 154 B -
12zyjjmq4oad1.js gzip N/A 5.72 kB -
18jvbdyomjd0w.js gzip N/A 151 B -
19eeqn1mjv0vt.js gzip N/A 156 B -
1dl-0_vny_nsm.js gzip N/A 155 B -
1gkxn3kvy0eri.js gzip N/A 154 B -
1j_7iw52-48fa.js gzip N/A 65.6 kB -
1k9cc4-gpa2cx.js gzip N/A 13.1 kB -
1kfiwrcr725kl.js gzip N/A 13.2 kB -
1n59uogejo81s.js gzip N/A 10.3 kB -
1npei3hlexdv3.js gzip N/A 9.99 kB -
1ssuiwj_rnpc5.js gzip N/A 8.77 kB -
1twnfn519w0_u.js gzip N/A 155 B -
2-phc9obd3nyd.js gzip N/A 8.77 kB -
24utq57r3l1cw.js gzip N/A 8.7 kB -
2fhjq6ek3srmr.js gzip N/A 8.69 kB -
2g0t7upz_v-hf.js gzip N/A 10.6 kB -
2h5nkoal80pda.js gzip N/A 45.2 kB -
2ia9qqy99aie9.js gzip N/A 13.6 kB -
2oza28kdqvoay.js gzip N/A 8.74 kB -
2t3-1eadj7woi.js gzip N/A 160 B -
2ui0dsrierofb.js gzip N/A 154 B -
2zh8-mmhujy8o.js gzip N/A 2.29 kB -
30h_m0irj-q6p.js gzip N/A 221 B -
32k2cm_v3snl5.js gzip N/A 154 B -
32s5d72o9mhg7.js gzip N/A 154 B -
33awzvk7o3i9x.js gzip N/A 71 kB -
37ejbfx1u9lpo.js gzip N/A 8.75 kB -
38c63ct4i1cy7.js gzip N/A 449 B -
3ggk1lzl49p05.js gzip N/A 165 B -
3jimpal3lvz5e.js gzip N/A 9.44 kB -
3sparlp-b3c_j.js gzip N/A 161 B -
3su6a4l8jbfth.js gzip N/A 3.53 kB -
3wb4pe4z4-aim.js gzip N/A 8.77 kB -
3zzrhjpzxeze1.js gzip N/A 153 B -
turbopack-02..vehg.js gzip N/A 3.79 kB -
turbopack-03..6f4n.js gzip N/A 3.8 kB -
turbopack-09..fbap.js gzip N/A 3.8 kB -
turbopack-0b..8zgv.js gzip N/A 3.8 kB -
turbopack-0b..9_57.js gzip N/A 3.8 kB -
turbopack-0j..7d6e.js gzip N/A 3.8 kB -
turbopack-1_..76lm.js gzip N/A 3.8 kB -
turbopack-13..4f4z.js gzip N/A 3.8 kB -
turbopack-1i..z722.js gzip N/A 3.8 kB -
turbopack-1i..flax.js gzip N/A 3.8 kB -
turbopack-1z..enel.js gzip N/A 3.81 kB -
turbopack-2i..h7js.js gzip N/A 3.8 kB -
turbopack-2r..kuk6.js gzip N/A 3.8 kB -
turbopack-3_..dvpc.js gzip N/A 3.81 kB -
Total 448 kB 448 kB ⚠️ +25 B

Server

Middleware
Canary PR Change
middleware-b..fest.js gzip 785 B 774 B 🟢 11 B (-1%)
Total 785 B 774 B ✅ -11 B
Build Details
Build Manifests
Canary PR Change
_buildManifest.js gzip 433 B 433 B
Total 433 B 433 B

📦 Webpack

Client

Main Bundles
Canary PR Change
2486.HASH.js gzip 169 B N/A -
3146-HASH.js gzip 64.2 kB N/A -
39fcf99b-HASH.js gzip 62.8 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 253 B
main-HASH.js gzip 39.7 kB 40.1 kB 🔴 +452 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.6 kB -
9597-HASH.js gzip N/A 4.65 kB -
e1ccab69-HASH.js gzip N/A 62.8 kB -
Total 239 kB 239 kB ✅ -209 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 🔴 +2.12 kB (+1%)
Total 411 kB 413 kB ⚠️ +1.8 kB
Middleware
Canary PR Change
middleware-b..fest.js gzip 616 B 618 B
middleware-r..fest.js gzip 156 B 155 B
middleware.js gzip 45.5 kB 45 kB 🟢 525 B (-1%)
edge-runtime..pack.js gzip 842 B 842 B
Total 47.1 kB 46.6 kB ✅ -524 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.82 MB 4.81 MB 🟢 5.76 kB (0%)
index.pack gzip 118 kB 120 kB 🔴 +1.5 kB (+1%)
index.pack.old gzip 119 kB 119 kB
Total 5.06 MB 5.05 MB ✅ -4.24 kB

🔄 Shared (bundler-independent)

Runtimes
Canary PR Change
app-page-exp...dev.js gzip 364 kB 364 kB
app-page-exp..prod.js gzip 201 kB 201 kB
app-page-tur...dev.js gzip 364 kB 364 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 361 kB 361 kB
app-page.run..prod.js gzip 199 kB 199 kB
app-route-ex...dev.js gzip 81.5 kB 81.5 kB
app-route-ex..prod.js gzip 55.4 kB 55.4 kB
app-route-tu...dev.js gzip 81.5 kB 81.5 kB
app-route-tu..prod.js gzip 55.4 kB 55.4 kB
app-route-tu...dev.js gzip 81.1 kB 81.1 kB
app-route-tu..prod.js gzip 55.1 kB 55.1 kB
app-route.ru...dev.js gzip 81.1 kB 81.1 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 33.9 kB 33.9 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.6 kB 54.6 kB
pages-turbo...prod.js gzip 39.6 kB 39.6 kB
pages.runtim...dev.js gzip 54.6 kB 54.6 kB
pages.runtim..prod.js gzip 39.5 kB 39.5 kB
server.runti..prod.js gzip 67.5 kB 67.5 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 ⚠️ +2 B
📝 Changed Files (2 files)

Files with changes:

  • pages-api.ru..time.prod.js
  • pages.runtime.prod.js
View diffs
pages-api.ru..time.prod.js

Diff too large to display

pages.runtime.prod.js

Diff too large to display

📎 Tarball URL
https://vercel-packages.vercel.app/next/commits/15199279837b38fbed2071459a4b254f5ab05915/next

Commit: 1519927

Comment thread crates/next-napi-bindings/src/next_api/project.rs Outdated
gaearon added a commit to gaearon/next.js that referenced this pull request Jul 20, 2026
Built on vercel#95942 (getSourceMapFilePath): findSourceMapURLDEV asks the
bundler for the emitted source map file of the referenced chunk and
returns its file: URL instead of inlining the payload as a data: URL.
React embeds the returned URL into every eval'd fake stack frame
function, each with a unique sourceURL, so inlined payloads made
Node.js parse and retain a copy of a potentially multi-megabyte source
map per fake function in a never-evicted cache, and made every eval
spend time linear in the payload size. On a component-heavy repro one
page load dropped from 29s to 7s (3s with a release binding) and from
2.7GB to 0.3GB of heap, with 2763 fake scripts referencing 0.2MB of
URLs instead of 1.3GB of inlined payloads.

file: URLs keep working for every consumer, unlike data: (works
everywhere, costs the above) or dev-server http: URLs (not resolvable
by Node.js or the dedicated Chrome DevTools frontend):
- attached debuggers read the emitted map from disk, whenever they
  attach,
- terminal symbolication resolves fake frames by devirtualizing them
  to the underlying chunk, whose source map Node.js knows. Also
  canonicalize devirtualized URLs to match Node.js' percent-encoded
  cache keys (e.g. chunks named [root-of-the-server]), and normalize
  single-slash file: URLs when printing frames.
- the implementation hook is shared via globalThis since source-maps
  is compiled both into the server runtime bundles (where Flight
  clients run) and next/dist/server (where the dev server registers
  it).

Includes a fixup for vercel#95942: append .map to the returned path (see
SourceMapAsset::path); the fake-frame e2e test caught the chunk path
being returned once the file: transport was active.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
gaearon added a commit to gaearon/next.js that referenced this pull request Jul 20, 2026
Built on vercel#95942 (getSourceMapFilePath): findSourceMapURLDEV asks the
bundler for the emitted source map file of the referenced chunk and
returns its file: URL instead of inlining the payload as a data: URL.
React embeds the returned URL into every eval'd fake stack frame
function, each with a unique sourceURL, so inlined payloads made
Node.js parse and retain a copy of a potentially multi-megabyte source
map per fake function in a never-evicted cache, and made every eval
spend time linear in the payload size. On a component-heavy repro one
page load dropped from 29s to 7s (3s with a release binding) and from
2.7GB to 0.3GB of heap, with 2763 fake scripts referencing 0.2MB of
URLs instead of 1.3GB of inlined payloads.

file: URLs keep working for every consumer, unlike data: (works
everywhere, costs the above) or dev-server http: URLs (not resolvable
by Node.js or the dedicated Chrome DevTools frontend):
- attached debuggers read the emitted map from disk, whenever they
  attach,
- terminal symbolication resolves fake frames by devirtualizing them
  to the underlying chunk, whose source map Node.js knows. Also
  canonicalize devirtualized URLs to match Node.js' percent-encoded
  cache keys (e.g. chunks named [root-of-the-server]), and normalize
  single-slash file: URLs when printing frames.
- the implementation hook is shared via globalThis since source-maps
  is compiled both into the server runtime bundles (where Flight
  clients run) and next/dist/server (where the dev server registers
  it).

Includes a fixup for vercel#95942: append .map to the returned path (see
SourceMapAsset::path); the fake-frame e2e test caught the chunk path
being returned once the file: transport was active.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
gaearon added a commit to gaearon/next.js that referenced this pull request Jul 20, 2026
Built on vercel#95942 (getSourceMapFilePath): findSourceMapURLDEV asks the
bundler for the emitted source map file of the referenced chunk and
returns its file: URL instead of inlining the payload as a data: URL.
React embeds the returned URL into every eval'd fake stack frame
function, each with a unique sourceURL, so inlined payloads made
Node.js parse and retain a copy of a potentially multi-megabyte source
map per fake function in a never-evicted cache, and made every eval
spend time linear in the payload size. On a component-heavy repro one
page load dropped from 29s to 7s (3s with a release binding) and from
2.7GB to 0.3GB of heap, with 2763 fake scripts referencing 0.2MB of
URLs instead of 1.3GB of inlined payloads.

file: URLs keep working for every consumer, unlike data: (works
everywhere, costs the above) or dev-server http: URLs (not resolvable
by Node.js or the dedicated Chrome DevTools frontend):
- attached debuggers read the emitted map from disk, whenever they
  attach,
- terminal symbolication resolves fake frames by devirtualizing them
  to the underlying chunk, whose source map Node.js knows. Also
  canonicalize devirtualized URLs to match Node.js' percent-encoded
  cache keys (e.g. chunks named [root-of-the-server]), and normalize
  single-slash file: URLs when printing frames.
- the implementation hook is shared via globalThis since source-maps
  is compiled both into the server runtime bundles (where Flight
  clients run) and next/dist/server (where the dev server registers
  it).

Includes a fixup for vercel#95942: append .map to the returned path (see
SourceMapAsset::path); the fake-frame e2e test caught the chunk path
being returned once the file: transport was active.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@lukesandberg
lukesandberg force-pushed the lukesandberg/get_source_map_url_sync branch from f8fdc4c to 7734b44 Compare July 20, 2026 02:20
Comment thread crates/next-napi-bindings/src/next_api/project.rs Outdated
gaearon added a commit that referenced this pull request Jul 20, 2026
Built on #95942 (getSourceMapFilePath): findSourceMapURLDEV asks the
bundler for the emitted source map file of the referenced chunk and
returns its file: URL instead of inlining the payload as a data: URL.
React embeds the returned URL into every eval'd fake stack frame
function, each with a unique sourceURL, so inlined payloads made
Node.js parse and retain a copy of a potentially multi-megabyte source
map per fake function in a never-evicted cache, and made every eval
spend time linear in the payload size. On a component-heavy repro one
page load dropped from 29s to 7s (3s with a release binding) and from
2.7GB to 0.3GB of heap, with 2763 fake scripts referencing 0.2MB of
URLs instead of 1.3GB of inlined payloads.

file: URLs keep working for every consumer, unlike data: (works
everywhere, costs the above) or dev-server http: URLs (not resolvable
by Node.js or the dedicated Chrome DevTools frontend):
- attached debuggers read the emitted map from disk, whenever they
  attach,
- terminal symbolication resolves fake frames by devirtualizing them
  to the underlying chunk, whose source map Node.js knows. Also
  canonicalize devirtualized URLs to match Node.js' percent-encoded
  cache keys (e.g. chunks named [root-of-the-server]), and normalize
  single-slash file: URLs when printing frames.
- the implementation hook is shared via globalThis since source-maps
  is compiled both into the server runtime bundles (where Flight
  clients run) and next/dist/server (where the dev server registers
  it).

Includes a fixup for #95942: append .map to the returned path (see
SourceMapAsset::path); the fake-frame e2e test caught the chunk path
being returned once the file: transport was active.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
gaearon added a commit that referenced this pull request Jul 20, 2026
Built on #95942 (getSourceMapFilePath): findSourceMapURLDEV asks the
bundler for the emitted source map file of the referenced chunk and
returns its file: URL instead of inlining the payload as a data: URL.
React embeds the returned URL into every eval'd fake stack frame
function, each with a unique sourceURL, so inlined payloads made
Node.js parse and retain a copy of a potentially multi-megabyte source
map per fake function in a never-evicted cache, and made every eval
spend time linear in the payload size. On a component-heavy repro one
page load dropped from 29s to 7s (3s with a release binding) and from
2.7GB to 0.3GB of heap, with 2763 fake scripts referencing 0.2MB of
URLs instead of 1.3GB of inlined payloads.

file: URLs keep working for every consumer, unlike data: (works
everywhere, costs the above) or dev-server http: URLs (not resolvable
by Node.js or the dedicated Chrome DevTools frontend):
- attached debuggers read the emitted map from disk, whenever they
  attach,
- terminal symbolication resolves fake frames by devirtualizing them
  to the underlying chunk, whose source map Node.js knows. Also
  canonicalize devirtualized URLs to match Node.js' percent-encoded
  cache keys (e.g. chunks named [root-of-the-server]), and normalize
  single-slash file: URLs when printing frames.
- the implementation hook is shared via globalThis since source-maps
  is compiled both into the server runtime bundles (where Flight
  clients run) and next/dist/server (where the dev server registers
  it).

Includes a fixup for #95942: append .map to the returned path (see
SourceMapAsset::path); the fake-frame e2e test caught the chunk path
being returned once the file: transport was active.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
gaearon added a commit that referenced this pull request Jul 20, 2026
Built on #95942 (getSourceMapFilePath): findSourceMapURLDEV asks the
bundler for the emitted source map file of the referenced chunk and
returns its file: URL instead of inlining the payload as a data: URL.
React embeds the returned URL into every eval'd fake stack frame
function, each with a unique sourceURL, so inlined payloads made
Node.js parse and retain a copy of a potentially multi-megabyte source
map per fake function in a never-evicted cache, and made every eval
spend time linear in the payload size. On a component-heavy repro one
page load dropped from 29s to 7s (3s with a release binding) and from
2.7GB to 0.3GB of heap, with 2763 fake scripts referencing 0.2MB of
URLs instead of 1.3GB of inlined payloads.

file: URLs keep working for every consumer, unlike data: (works
everywhere, costs the above) or dev-server http: URLs (not resolvable
by Node.js or the dedicated Chrome DevTools frontend):
- attached debuggers read the emitted map from disk, whenever they
  attach,
- terminal symbolication resolves fake frames by devirtualizing them
  to the underlying chunk, whose source map Node.js knows. Also
  canonicalize devirtualized URLs to match Node.js' percent-encoded
  cache keys (e.g. chunks named [root-of-the-server]), and normalize
  single-slash file: URLs when printing frames.
- the implementation hook is shared via globalThis since source-maps
  is compiled both into the server runtime bundles (where Flight
  clients run) and next/dist/server (where the dev server registers
  it).

Includes a fixup for #95942: append .map to the returned path (see
SourceMapAsset::path); the fake-frame e2e test caught the chunk path
being returned once the file: transport was active.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
gaearon added a commit that referenced this pull request Jul 20, 2026
Built on #95942 (getSourceMapFilePath): findSourceMapURLDEV asks the
bundler for the emitted source map file of the referenced chunk and
returns its file: URL instead of inlining the payload as a data: URL.
React embeds the returned URL into every eval'd fake stack frame
function, each with a unique sourceURL, so inlined payloads made
Node.js parse and retain a copy of a potentially multi-megabyte source
map per fake function in a never-evicted cache, and made every eval
spend time linear in the payload size. On a component-heavy repro one
page load dropped from 29s to 7s (3s with a release binding) and from
2.7GB to 0.3GB of heap, with 2763 fake scripts referencing 0.2MB of
URLs instead of 1.3GB of inlined payloads.

file: URLs keep working for every consumer, unlike data: (works
everywhere, costs the above) or dev-server http: URLs (not resolvable
by Node.js or the dedicated Chrome DevTools frontend):
- attached debuggers read the emitted map from disk, whenever they
  attach,
- terminal symbolication resolves fake frames by devirtualizing them
  to the underlying chunk, whose source map Node.js knows. Also
  canonicalize devirtualized URLs to match Node.js' percent-encoded
  cache keys (e.g. chunks named [root-of-the-server]), and normalize
  single-slash file: URLs when printing frames.
- the implementation hook is shared via globalThis since source-maps
  is compiled both into the server runtime bundles (where Flight
  clients run) and next/dist/server (where the dev server registers
  it).

Includes a fixup for #95942: append .map to the returned path (see
SourceMapAsset::path); the fake-frame e2e test caught the chunk path
being returned once the file: transport was active.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Fixes review feedback on get_source_map_file_path:

- It returned the chunk's file:// URL, not the source map's. Resolve the
  chunk's referenced SourceMapAsset and use its own path(), which is
  authoritative in every mode (content-hashed prod client chunks derive the
  map name from the map's own content, so <chunk>.map is wrong there).
- Client source map assets live on a VirtualFileSystem; rebase them onto the
  disk-backed node_root (as emit does) before building the file:// URL.
- Discriminate server-vs-client by whether a chunk exists at the path and
  references a SourceMapAsset, instead of generating the source map content
  just to test is_content() -- the file-path getter no longer pays for
  source-map codegen.

Also document the production-extension path in get_source_map_asset.
@lukesandberg
lukesandberg force-pushed the lukesandberg/get_source_map_url_sync branch from e9a61d9 to 1519927 Compare July 20, 2026 16:47
} else {
// Not under a known output root (e.g. produced on some other filesystem); we can't map
// it to a disk `file://` URL.
return Ok(Vc::cell(None));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is an error condition

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