Skip to content

Don't load the app-page runtime in proxy.ts - #100384

Merged
timneutkens merged 3 commits into
vercel:canaryfrom
tobiaslins:claude/proxy-no-page-runtime
Oct 19, 2026
Merged

timneutkens merged 3 commits into
vercel:canaryfrom
tobiaslins:claude/proxy-no-page-runtime

Conversation

@tobiaslins

@tobiaslins tobiaslins commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Cause
importing anything from next/server also loads connection(), which loads dynamic-rendering.ts. That file imported React at the top just to read an owner stack in development, and in a proxy build this pulled in the 688 KB app-page-turbo.runtime.prod.js.

Fix
React is now imported lazily. No public API change.
Effect on a minimal proxy, on canary: the cold path goes from 53.8 ms to 39.1 ms (−27%) and JS loaded from 1,466 KB to 748 KB. The page runtime and React also drop out of middleware.js.nft.json, so the deployed proxy function is smaller.

Test
the new test/production/app-dir/proxy-no-page-runtime asserts the proxy's trace has no page runtime or React in it. It fails without the fix and passes with it on Turbopack and webpack.
Existing tests that still pass: app-middleware-proxy and proxy-missing-export in production with Turbopack, and the cache-components-errors suites in dev with Turbopack.

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Tests Passed

Commit: c258d40

Comment thread test/production/app-dir/proxy-no-page-runtime/proxy-no-page-runtime.test.ts Outdated
@tobiaslins
tobiaslins requested a review from a team October 19, 2026 09:33
Comment thread packages/next/src/server/app-render/dynamic-rendering.ts Outdated
Comment thread test/production/app-dir/proxy-no-page-runtime/proxy-no-page-runtime.test.ts Outdated
@lubieowoce

Copy link
Copy Markdown
Member

Behavior change
on the edge runtime in development, dynamic-rendering errors lose the React owner stack and fall back to the component stack. The existing applyOwnerStack already works the same way; production is unaffected.

hmm wait what's causing this? this isn't obvious to me just from looking at this PR

@tobiaslins

Copy link
Copy Markdown
Contributor Author

Behavior change
on the edge runtime in development, dynamic-rendering errors lose the React owner stack and fall back to the component stack. The existing applyOwnerStack already works the same way; production is unaffected.

hmm wait what's causing this? this isn't obvious to me just from looking at this PR

not true anymore! updated the initial description

Co-authored-by: Janka Uryga <lolzatu2@gmail.com>
@timneutkens
timneutkens merged commit 6197e56 into vercel:canary Oct 19, 2026
119 checks passed
acdlite added a commit that referenced this pull request Oct 20, 2026
Backports [Don't load the app-page runtime in proxy.ts
(#100384)](#100384) to
`releases/lts/active` for the next 16.4.x patch. The cherry-pick applied
cleanly.

<!-- NEXT_JS_LLM -->

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Tobias Lins <me@tobi.sh>
Co-authored-by: Janka Uryga <lolzatu2@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants