test(instant-validation): document usePathname() stack-trace attribution today#94422
Draft
aurorascharff wants to merge 5 commits into
Draft
test(instant-validation): document usePathname() stack-trace attribution today#94422aurorascharff wants to merge 5 commits into
aurorascharff wants to merge 5 commits into
Conversation
…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.
Contributor
Tests PassedCommit: 18567a9 |
Contributor
Stats from current PR✅ No significant changes detected📊 All Metrics📖 Metrics GlossaryDev Server Metrics:
Build Metrics:
Change Thresholds:
⚡ Dev Server
📦 Dev Server (Webpack) (Legacy)📦 Dev Server (Webpack)
⚡ Production Builds
📦 Production Builds (Webpack) (Legacy)📦 Production Builds (Webpack)
📦 Bundle SizesBundle Sizes⚡ TurbopackClient Main Bundles
Server Middleware
Build DetailsBuild Manifests
📦 WebpackClient Main Bundles
Polyfills
Pages
Server Edge SSR
Middleware
Build DetailsBuild Manifests
Build Cache
🔄 Shared (bundler-independent)Runtimes
📎 Tarball URLCommit: 18567a9 |
eps1lon
reviewed
Jun 3, 2026
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)", | ||
| ], | ||
| } | ||
| `) | ||
| }) |
Member
There was a problem hiding this comment.
This should include a dev assertion to ensure there is a proper stack.
eps1lon
reviewed
Jun 3, 2026
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 |
Member
There was a problem hiding this comment.
FYI this is a React decision. Error stacks have less fidelity in production for performance reasons.
Contributor
Author
There was a problem hiding this comment.
Thats what i learned, but @gnoff has a PR to change that i think?
Contributor
Author
There was a problem hiding this comment.
eps1lon
reviewed
Jun 3, 2026
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) |
Member
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.<unknown>.<minified>.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.