Skip to content

Show dependency frames in prerender diagnostics - #102189

Closed
aurorascharff wants to merge 6 commits into
canaryfrom
codex/dependency-stack-frames
Closed

aurorascharff wants to merge 6 commits into
canaryfrom
codex/dependency-stack-frames

Conversation

@aurorascharff

@aurorascharff aurorascharff commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Closed by #102471.

What?

Show third-party dependency call sites in next build --debug-prerender and in the dev overlay's expanded validation-error stacks.

Why?

When a dependency calls new Date() during prerendering, ignore-listing can hide the offending call and leave only the page's component mount site. The suggested debugging commands then fail to identify the dependency. Reproduction.

How?

Reveal dependency frames in debug-prerender output while retaining framework filtering and the React stack cutoff. Preserve dependency frames specifically when serializing validation errors, keeping them collapsed by default in the overlay. Normalize external Webpack frame URLs for display.

Console output

Same command before and after: next build --debug-prerender --webpack.

Before

Error: Route "/external": Next.js encountered the unstable value `new Date()` while prerendering.
    at Page (app/external/page.jsx:4:10)
  2 |
  3 | export default function Page() {
> 4 |   return <BlockingWidget />
    |          ^
  5 | }

After

Error: Route "/external": Next.js encountered the unstable value `new Date()` while prerendering.
    at readCurrentTime (node_modules/external-time/index.js:2:10)
    at BlockingWidget (node_modules/external-time/index.js:6:10)
    at Page (app/external/page.jsx:4:10)
  2 |
  3 | export default function Page() {
> 4 |   return <BlockingWidget />
    |          ^
  5 | }

Excerpts from the same fixture on the base commit and PR branch. Paths are normalized relative to the app; the explanatory message and fix suggestions are omitted.

Dev overlay

Both screenshots use Next.js 16.5.0-canary.59 with Webpack and the ignore-listed frames expanded. Before, the dependency call sites are absent. After, the expanded stack includes readCurrentTime and BlockingWidget with their dependency file locations. The collapsed view and the code frame still point at <BlockingWidget /> in the page.

Before

Before: expanded stack omits the dependency call sites

After

After: expanded stack shows the dependency call sites

Verification

  • Regression coverage passes in dev and build mode with Turbopack and Webpack, including bundled/external dependencies and in-process/worker validation. All 35 source-map unit cases pass.
  • pnpm test-dev-turbo test/development/app-dir/error-overlay/error-ignored-frames/error-ignored-frames.test.ts
  • pnpm test-dev-webpack test/development/app-dir/error-overlay/error-ignored-frames/error-ignored-frames.test.ts

@vercel

vercel Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Vercel Agent finished reviewing your changes and found no issues.
e3bfacb • Mon, 23 Nov 2026 16:09:03 GMT • 1m 21s • Details

Checked (2)

     Check Location
The latest merge preserves the reviewed implementation and regression coverage.
Compared the complete previous and current PR diffs with cmp: identical; git diff dab861c HEAD also reports no changes to any PR-touched file.
source-maps.ts:132
Validation-worker error delivery retains the development-only filter guard.
Traced the NODE_ENV conditional binding to the filterStackFrame option passed into renderToNodeFlightStream.
dev-validation-error-delivery.ts:6
Review steps

     Step Time
Preparing the workspace 17.5s
Analyzing the changes 59.1s
Finalizing the review 4.5s

@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Tests Passed

Commit: e3bfacb
View workflow run

@github-actions github-actions Bot added Documentation Related to Next.js' official documentation. tests type: next labels Nov 21, 2026
@aurorascharff
aurorascharff marked this pull request as ready for review November 21, 2026 12:33

@vercel vercel Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Vercel Agent Verified Review approves this commit: no issues found, and the change meets this repository’s review rules. Report

@vercel

vercel Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Vercel Agent Verified Review finished reviewing your changes and approved this pull request.
e3bfacb • Mon, 23 Nov 2026 16:15:04 GMT • 7m 16s • Report • Details

Everything checks out under the repository’s review policy.

Summary

Shows third-party dependency stack frames in two places. next build --debug-prerender now prints them, dimmed, via a new __NEXT_SHOW_DEPENDENCY_FRAMES env var. Dev validation errors sent to the browser now keep them, through a new filterStackFrameForErrorDEV Flight filter that also resolves bundled chunks to their original source. Separately, about://React/...file:// frame URLs are now normalized in the webpack dev middleware.

Questions for the author (2)

  • Next.js's own runtime dependencies that live outside the next/ folder (e.g. styled-jsx, @swc/helpers, server-only, or packages nested under node_modules/next/node_modules/) now count as third-party, so their frames will appear in debug-prerender output and in the expanded overlay stack. Is that intended?
  • The new fixture sets cacheComponents: true, so both test-infra variants run the same configuration. Is that acceptable given that the fixture depends on Cache Components' sync-IO error?
Checked (5)

     Check Location
Framework packages (next, @next/, react, react-dom, react-server-dom-, scheduler) are never classified as dependency frames, even under pnpm layouts.
Read the lastIndexOf('node_modules/') slice and the exclusion regex. Ran pnpm testonly packages/next/src/server/lib/source-maps.test.ts on the head: all 35 cases pass.
source-maps.ts:133
Next's precompiled runtime frames stay filtered in the error payload, even after resolving them through the source map.
Checked dist/compiled/next-server/app-page{,-turbo}.runtime.dev.js.map in the built head: none of their 388–390 sources contain node_modules/, so findEntry can never classify them as third-party.
source-maps.ts:151
Without --debug-prerender, console stack output is unchanged, because the dependency-frame branch only runs when __NEXT_SHOW_DEPENDENCY_FRAMES is 'true'.
grep shows the env var is set only in next-build.ts:118 inside if (debugPrerender).
patch-error-inspect.ts:568
The React bottom-frame cutoff and code-frame choice are unchanged; dependency frames stay marked ignored.
Read parseAndSourceMap. The cutoff is still skipped only when showIgnoreListed is set, and sourceFrame selection still requires !ignored.
patch-error-inspect.ts:492
The new error filter is dev-only and is safe on Edge, where findSourceMap is a no-op.
Read the guarded require and the edge noSourceMap fallback at source-maps.ts:9-12.
app-render.tsx:470
Review steps

     Step Time
Sandbox set up 37.7s
Repository rules read: REVIEW.md and AGENTS.md files (4)
Agent review: 12 of 20 changed files opened, 3 commands run 6m 37s
Repros run on the head and the base (0), findings graded (0) 2.0s

Read the full report ↗ (Download report.json • report.md)

@vercel vercel Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Vercel Agent Verified Review approves this commit: no issues found, and the change meets this repository’s review rules. Report

@vercel vercel Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Vercel Agent Verified Review approves this commit: no issues found, and the change meets this repository’s review rules. Report

@vercel vercel Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Vercel Agent Verified Review approves this commit: no issues found, and the change meets this repository’s review rules. Report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation Related to Next.js' official documentation. tests type: next

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant