Skip to content

test(instant-validation): document usePathname() stack-trace attribution today#94422

Draft
aurorascharff wants to merge 5 commits into
canaryfrom
aurorascharff/use-pathname-stack-trace-fixtures
Draft

test(instant-validation): document usePathname() stack-trace attribution today#94422
aurorascharff wants to merge 5 commits into
canaryfrom
aurorascharff/use-pathname-stack-trace-fixtures

Conversation

@aurorascharff
Copy link
Copy Markdown
Contributor

@aurorascharff aurorascharff commented Jun 3, 2026

Three bug-witness fixtures + snapshots that pin down today's usePathname() stack-frame attribution. The snapshots are intentionally wrong — they bake the current bug so a fix shows up clearly in diff review.

  • Build, no wrapper — function frame is <unknown>.
  • Build, three wrappers deep — function frame is an SWC-minified letter; non-deterministic across module-graph orderings, snapshot normalizes to <minified>.
  • Dev, fallback param — overlay attributes the error to the parent's JSX line, reports E1265 "uncached data" with Cache/Stream/Block cards, and drops the hook caller from the stack.

Dev fixture lives under app/default/ (no root <Suspense> above body) so the validation hole isn't swallowed before the Insight fires.

Related: #94235, #94387.

…attribution

Adds three failing-on-purpose fixtures + snapshots that capture how the
instant validator currently attributes errors thrown by client URL hooks.
Today the framework loses the React component frame when usePathname()
suspends during validation; the snapshots bake the current buggy shape
so any future fix shows up clearly in review.

Build-mode (test/e2e/app-dir/instant-validation-build):
- pathname/invalid-use-pathname-missing-params-no-wrapper/[one]/[two]:
  usePathname() called at the top of a Client Component body. Stack
  frame degrades to '<unknown>' even though file/line/column are correct.
- pathname/invalid-use-pathname-deep-component/[one]/[two]:
  usePathname() buried under three Client Component wrappers. Stack
  frame shows the SWC-minified single-letter name instead of
  'PathnameReader'. The minified name is non-deterministic across
  module-graph orderings, so the snapshot normalizes 'at X (' to
  'at <minified> ('.

Dev-mode (test/e2e/app-dir/instant-validation):
- default/invalid-use-pathname-no-samples/[slug]:
  No unstable_instant config, [slug] is a fallback route param. The dev
  overlay reports the parent page.tsx's '<PathnameLabel />' JSX line
  with code E1265 'uncached data during prerendering' and label
  'Blocking Route' — instead of pointing at the actual usePathname()
  call inside pathname-label.tsx and using a URL-data category.

The dev fixture lives under app/default/ (no root Suspense above body)
so the validation hole isn't swallowed before the Insight can fire.

Tracks #94235 and #94387 docs follow-ups.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 3, 2026

Tests Passed

Commit: 18567a9

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 3, 2026

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 812ms ▁████
Cold (Ready in log) 800ms 800ms ▁▇▇▆▇
Cold (First Request) 1.286s 1.256s ▁▅▅▁▆
Warm (Listen) 811ms 811ms ▁▆▆▆█
Warm (Ready in log) 800ms 793ms ▁▇▇▅█
Warm (First Request) 625ms 609ms ▁██▁█
📦 Dev Server (Webpack) (Legacy)

📦 Dev Server (Webpack)

Metric Canary PR Change Trend
Cold (Listen) 811ms 810ms █████
Cold (Ready in log) 784ms 784ms ▆▇▆██
Cold (First Request) 3.262s 3.260s ▃▃▃▃▇
Warm (Listen) 811ms 811ms █████
Warm (Ready in log) 784ms 785ms ▆▇▆██
Warm (First Request) 3.256s 3.297s ▄▂▃▄█

⚡ Production Builds

Metric Canary PR Change Trend
Fresh Build 5.260s 5.221s ▁▄▄▂█
Cached Build 5.256s 5.233s ▁▆▇▃█
📦 Production Builds (Webpack) (Legacy)

📦 Production Builds (Webpack)

Metric Canary PR Change Trend
Fresh Build 23.966s 23.951s ▁▁▃▄▃
Cached Build 23.725s 23.861s ▁▁▁▂▄
node_modules Size 508 MB 508 MB █████
📦 Bundle Sizes

Bundle Sizes

⚡ Turbopack

Client

Main Bundles
Canary PR Change
0_ge-tzpfj3ad.js gzip 7.61 kB N/A -
04hm05ar7kldw.js gzip 5.73 kB N/A -
0c3qorn-caaqm.js gzip 159 B N/A -
0cz1d0mv5g_q7.js gzip 39.4 kB 39.4 kB
0dvitrl5zg37g.js gzip 8.82 kB N/A -
0jr32pwdgce0n.js gzip 50.7 kB N/A -
0sf7ysou-72zd.js gzip 8.71 kB N/A -
0zr-u63abf5fh.js gzip 160 B N/A -
1-vh6er301c5a.js gzip 154 B N/A -
10r37zut_gb-7.js gzip 154 B N/A -
157abun3hwc_s.js gzip 10.3 kB N/A -
180qj90dxm04k.js gzip 168 B N/A -
1bd7epfpozz6a.js gzip 151 B N/A -
1cu7zeozp4f57.js gzip 155 B N/A -
1elt1qium-r2m.css gzip 115 B 115 B
1jpaub6y8xlfr.js gzip 2.3 kB N/A -
1m4uhe3-4ssti.js gzip 155 B N/A -
1ot0mvscrc_uf.js gzip 233 B N/A -
1ptroxnl-4qbi.js gzip 156 B N/A -
2_m3xv2uq3sjc.js gzip 1.46 kB N/A -
24y34mwgrkqp4.js gzip 8.78 kB N/A -
25spn-0d1nba7.js gzip 156 B N/A -
2c-fd4y1zozz8.js gzip 8.79 kB N/A -
2d7416h_xd36x.js gzip 8.71 kB N/A -
2du4zd3fxzjre.js gzip 155 B N/A -
2htmz9b4i71kq.js gzip 65.6 kB N/A -
2lmb9--hai0j3.js gzip 156 B N/A -
2lyuhit6rn8fy.js gzip 9.44 kB N/A -
2q0gr8wfr3jwl.js gzip 8.77 kB N/A -
2r53k857auyzb.js gzip 154 B N/A -
2t9e75oz6r0zp.js gzip 8.76 kB N/A -
2uku_olcn15b7.js gzip 8.79 kB N/A -
30r8mm-46bdqy.js gzip 220 B 220 B
31yqmlovygr53.js gzip 71 kB N/A -
340x4rsgf3u0g.js gzip 13.8 kB N/A -
3c1jdxkzlb8oq.js gzip 12.9 kB N/A -
3inab2jybr4k9.js gzip 450 B N/A -
3jkm5tdjvaf_q.js gzip 13.1 kB N/A -
3mt67agm5wp40.js gzip 10.6 kB N/A -
3saabek4kohwi.js gzip 10 kB N/A -
4189xmby9yu1p.js gzip 13.6 kB N/A -
turbopack-09..0dhq.js gzip 4.23 kB N/A -
turbopack-0w..vjgz.js gzip 4.23 kB N/A -
turbopack-0z..hmgr.js gzip 4.23 kB N/A -
turbopack-1a..9q21.js gzip 4.23 kB N/A -
turbopack-1j..unbs.js gzip 4.23 kB N/A -
turbopack-1o..pa0i.js gzip 4.23 kB N/A -
turbopack-1x..4-p-.js gzip 4.23 kB N/A -
turbopack-1z..5rt6.js gzip 4.23 kB N/A -
turbopack-2-..bg5x.js gzip 4.23 kB N/A -
turbopack-20..60qk.js gzip 4.21 kB N/A -
turbopack-24..dn9e.js gzip 4.23 kB N/A -
turbopack-30..yxvh.js gzip 4.22 kB N/A -
turbopack-32..mzl8.js gzip 4.24 kB N/A -
turbopack-35..ljq-.js gzip 4.23 kB N/A -
0_i7nqgx23st7.js gzip N/A 10 kB -
06puhytyxk31p.js gzip N/A 8.82 kB -
0am6com3_b1iw.js gzip N/A 152 B -
0j42f9zonj0wd.js gzip N/A 13 kB -
0m34gln_kt4fg.js gzip N/A 5.73 kB -
0ni54skfvsniu.js gzip N/A 50.7 kB -
0pa0lgrmxss-q.js gzip N/A 154 B -
141vd7boyx0bj.js gzip N/A 169 B -
19p86ionwzhuk.js gzip N/A 155 B -
1d1x-85qdrxsj.js gzip N/A 160 B -
1g3q1ww01thnl.js gzip N/A 2.3 kB -
1hraqxuiymq6v.js gzip N/A 8.79 kB -
1l9un1sl77287.js gzip N/A 1.46 kB -
1o9sbenyz-3_a.js gzip N/A 155 B -
1qzwwpvf_g19r.js gzip N/A 156 B -
2147zgtf14z-q.js gzip N/A 234 B -
23bz3xsg-5-1s.js gzip N/A 8.71 kB -
25a4cl1y4xm5u.js gzip N/A 156 B -
27441mytv7pbm.js gzip N/A 9.43 kB -
2cjkwjgm1zcfs.js gzip N/A 8.71 kB -
2gtio0ehxu_18.js gzip N/A 7.61 kB -
2o7klqm6ne75h.js gzip N/A 71 kB -
2scd8zaoyb8md.js gzip N/A 8.79 kB -
2st_qs6p_9us0.js gzip N/A 13.1 kB -
2wh1auw71zo9w.js gzip N/A 158 B -
2zo2exm1d8qj1.js gzip N/A 13.6 kB -
30oszfu8bgqbc.js gzip N/A 13.9 kB -
340n-zp8ss2_e.js gzip N/A 157 B -
347g5vwjszt8s.js gzip N/A 162 B -
3dv_4owika8e8.js gzip N/A 65.6 kB -
3hn75zuxly9az.js gzip N/A 10.3 kB -
3hqh7m128tvsn.js gzip N/A 8.77 kB -
3hqti_t-zy1x4.js gzip N/A 449 B -
3iozwku-uhmhd.js gzip N/A 155 B -
3mnawenie1flm.js gzip N/A 8.76 kB -
3ubsozlu6zs38.js gzip N/A 10.6 kB -
3wrberqrh3a1d.js gzip N/A 155 B -
43iwfqjnx1cy_.js gzip N/A 8.78 kB -
turbopack-08..h3xs.js gzip N/A 4.23 kB -
turbopack-09..irw4.js gzip N/A 4.23 kB -
turbopack-0a..0lj-.js gzip N/A 4.23 kB -
turbopack-0b..m2tz.js gzip N/A 4.23 kB -
turbopack-0s..vmd0.js gzip N/A 4.23 kB -
turbopack-12..qze9.js gzip N/A 4.23 kB -
turbopack-16..khx-.js gzip N/A 4.23 kB -
turbopack-1x..0jdi.js gzip N/A 4.23 kB -
turbopack-2y..-u-4.js gzip N/A 4.23 kB -
turbopack-36..qevp.js gzip N/A 4.23 kB -
turbopack-3c..5_1m.js gzip N/A 4.24 kB -
turbopack-3j..rxz8.js gzip N/A 4.23 kB -
turbopack-3k..3xer.js gzip N/A 4.23 kB -
turbopack-3v..v3us.js gzip N/A 4.21 kB -
Total 470 kB 470 kB ⚠️ +44 B

Server

Middleware
Canary PR Change
middleware-b..fest.js gzip 726 B 727 B
Total 726 B 727 B ⚠️ +1 B
Build Details
Build Manifests
Canary PR Change
_buildManifest.js gzip 432 B 429 B
Total 432 B 429 B ✅ -3 B

📦 Webpack

Client

Main Bundles
Canary PR Change
2258-HASH.js gzip 61.7 kB N/A -
2266-HASH.js gzip 4.69 kB N/A -
3317.HASH.js gzip 169 B N/A -
4866-HASH.js gzip 5.64 kB N/A -
9e302639-HASH.js gzip 62.8 kB N/A -
framework-HASH.js gzip 59.5 kB 59.5 kB
main-app-HASH.js gzip 254 B 254 B
main-HASH.js gzip 39.9 kB 39.9 kB
webpack-HASH.js gzip 1.68 kB 1.68 kB
175fd0fd-HASH.js gzip N/A 62.8 kB -
2596-HASH.js gzip N/A 5.63 kB -
34-HASH.js gzip N/A 61.7 kB -
5691.HASH.js gzip N/A 169 B -
9156-HASH.js gzip N/A 4.68 kB -
Total 236 kB 236 kB ✅ -12 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 193 B 193 B
_error-HASH.js gzip 181 B 182 B
css-HASH.js gzip 334 B 332 B
dynamic-HASH.js gzip 1.79 kB 1.81 kB
edge-ssr-HASH.js gzip 255 B 255 B
head-HASH.js gzip 351 B 348 B
hooks-HASH.js gzip 385 B 384 B
image-HASH.js gzip 580 B 580 B
index-HASH.js gzip 257 B 259 B
link-HASH.js gzip 2.51 kB 2.52 kB
routerDirect..HASH.js gzip 318 B 319 B
script-HASH.js gzip 387 B 386 B
withRouter-HASH.js gzip 316 B 316 B
1afbb74e6ecf..834.css gzip 106 B 106 B
Total 7.97 kB 7.99 kB ⚠️ +19 B

Server

Edge SSR
Canary PR Change
edge-ssr.js gzip 126 kB 126 kB
page.js gzip 278 kB 272 kB 🟢 5.31 kB (-2%)
Total 404 kB 398 kB ✅ -5.53 kB
Middleware
Canary PR Change
middleware-b..fest.js gzip 618 B 615 B
middleware-r..fest.js gzip 155 B 155 B
middleware.js gzip 44.4 kB 44.8 kB
edge-runtime..pack.js gzip 842 B 842 B
Total 46 kB 46.4 kB ⚠️ +375 B
Build Details
Build Manifests
Canary PR Change
_buildManifest.js gzip 719 B 717 B
Total 719 B 717 B ✅ -2 B
Build Cache
Canary PR Change
0.pack gzip 4.51 MB 4.51 MB
index.pack gzip 114 kB 115 kB
index.pack.old gzip 115 kB 116 kB
Total 4.74 MB 4.74 MB ⚠️ +4.89 kB

🔄 Shared (bundler-independent)

Runtimes
Canary PR Change
app-page-exp...dev.js gzip 354 kB 354 kB
app-page-exp..prod.js gzip 196 kB 196 kB
app-page-tur...dev.js gzip 354 kB 354 kB
app-page-tur..prod.js gzip 196 kB 196 kB
app-page-tur...dev.js gzip 350 kB 350 kB
app-page-tur..prod.js gzip 194 kB 194 kB
app-page.run...dev.js gzip 350 kB 350 kB
app-page.run..prod.js gzip 194 kB 194 kB
app-route-ex...dev.js gzip 77.5 kB 77.5 kB
app-route-ex..prod.js gzip 52.9 kB 52.9 kB
app-route-tu...dev.js gzip 77.6 kB 77.6 kB
app-route-tu..prod.js gzip 52.9 kB 52.9 kB
app-route-tu...dev.js gzip 77.2 kB 77.2 kB
app-route-tu..prod.js gzip 52.7 kB 52.7 kB
app-route.ru...dev.js gzip 77.1 kB 77.1 kB
app-route.ru..prod.js gzip 52.7 kB 52.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 44.3 kB 44.3 kB
pages-api-tu..prod.js gzip 33.8 kB 33.8 kB
pages-api.ru...dev.js gzip 44.3 kB 44.3 kB
pages-api.ru..prod.js gzip 33.7 kB 33.7 kB
pages-turbo....dev.js gzip 53.7 kB 53.7 kB
pages-turbo...prod.js gzip 39.4 kB 39.4 kB
pages.runtim...dev.js gzip 53.6 kB 53.6 kB
pages.runtim..prod.js gzip 39.4 kB 39.4 kB
server.runti..prod.js gzip 63.2 kB 63.2 kB
use-cache-pr...dev.js gzip 70.4 kB 70.4 kB
use-cache-pr...dev.js gzip 70.4 kB 70.4 kB
use-cache-pr...dev.js gzip 68.7 kB 68.7 kB
use-cache-pr...dev.js gzip 68.7 kB 68.7 kB
Total 3.39 MB 3.39 MB
📎 Tarball URL
https://vercel-packages.vercel.app/next/commits/18567a9421fb88127a3dd8dd6a4f844ccea2eeb0/next

Commit: 18567a9

Comment on lines +1897 to +1939
it('invalid - usePathname() in a client component on a route with a fallback param', async () => {
if (!isNextDev) {
// Build-mode coverage lives in
// test/e2e/app-dir/instant-validation-build/instant-validation-build.test.ts
// under the `pathname` describe block. This test asserts the dev
// overlay's frame attribution.
return
}
if (isClientNav) {
// The bug we're capturing only manifests on initial load, where the
// dev validation runs server-side and the React stack is what gets
// surfaced. Skip the client-nav case so the inline snapshot below
// doesn't have to capture two different shapes.
return
}
// The fixture lives under `default/` (no root Suspense above body) so
// the validation hole isn't swallowed before the Insight can fire.
// `[slug]` is a fallback route param with no `unstable_samples`, so
// `usePathname()` suspends during dev validation — mirroring the
// test-app's repro at `88-client-use-pathname/[slug]`.
const browser = await navigateTo(
'/default/invalid-use-pathname-no-samples/123'
)
// Snapshot the dev redbox shape so the bug surface is visible:
// today the overlay reports the parent page.tsx's render JSX as the
// source, not the `usePathname()` call inside pathname-label.tsx,
// and routes the user toward Cache / Stream / Block cards even
// though `usePathname` is URL data, not cacheable data.
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1265",
"description": "Next.js encountered uncached data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
"source": "app/default/invalid-use-pathname-no-samples/[slug]/page.tsx (11:7) @ Page
> 11 | <PathnameLabel />
| ^",
"stack": [
"Page app/default/invalid-use-pathname-no-samples/[slug]/page.tsx (11:7)",
],
}
`)
})
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.

This should include a dev assertion to ensure there is a proper stack.

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.

Like this? d7285c6

Comment on lines +1897 to +1898
// Today the dev overlay misattributes usePathname() errors to the
// parent's JSX line instead of the actual hook call site. When the
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.

FYI this is a React decision. Error stacks have less fidelity in production for performance reasons.

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.

Thats what i learned, but @gnoff has a PR to change that i think?

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.

Comment on lines +827 to +828
"Error: Route "/pathname/invalid-use-pathname-missing-params-no-wrapper/[one]/[two]" called usePathname() but param "two" is not defined in the \`unstable_samples\` of \`unstable_instant\`. usePathname() requires all route params to be provided.
at <unknown> (app/(default)/pathname/invalid-use-pathname-missing-params-no-wrapper/[one]/[two]/pathname-reader.tsx:6:20)
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.

That doesn't really tell us stack attribution is working because it's just the sync error from misuing samples. The codeframe is the one we finally want. But it's broken at the moment.

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