mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #1036] [MERGED] refactor(app-rsc): move request lifecycle into typed handler #1037
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#1037
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/1036
Author: @NathanDrake2406
Created: 5/3/2026
Status: ✅ Merged
Merged: 5/3/2026
Merged by: @james-elicx
Base:
main← Head:nathan/finish-app-rsc-entry📝 Commits (3)
fc365b7refactor(app-rsc): introduce app-rsc-request-normalization module89d088drefactor(app-rsc): wire normalizeRscRequest into the entry and callsitesd2fed81refactor(app-rsc): move request lifecycle into typed handler📊 Changes
6 files changed (+1116 additions, -671 deletions)
View changed files
📝
packages/vinext/src/entries/app-rsc-entry.ts(+315 -576)➕
packages/vinext/src/server/app-rsc-handler.ts(+494 -0)📝
packages/vinext/src/server/app-rsc-request-normalization.ts(+2 -0)📝
tests/app-router.test.ts(+56 -94)➕
tests/app-rsc-handler.test.ts(+248 -0)📝
tests/app-rsc-request-normalization.test.ts(+1 -1)📄 Description
The refactor to end them all!
What this changes
Moves the App Router RSC request lifecycle out of the generated virtual entry and into a typed
createAppRscHandlerruntime helper.The generated RSC entry now describes app shape and route-specific wiring: route manifests, metadata routes, root params, dispatch closures, action adapters, fallback renderers, and config values. The normal module owns behavior: normalization, config redirects, middleware handoff, rewrites, metadata/public files, server actions, route-handler/page dispatch, 404 cleanup, request ALS setup, and response finalization.
Why
The App RSC entry had grown into a large generated runtime subsystem. That violated the working principle for this refactor: codegen should describe the app shape; normal modules should implement behavior.
It also made behavior hard to test directly. Important lifecycle semantics were protected by string assertions against generated code rather than behavior tests against an importable module.
Relevant Next.js source references:
beforeFiles,afterFiles, thenfallbackrewrites in server routing: server-utils.ts#L350-L365next-action: app-router-headers.ts#L1-L3Headersand Node request headers: server-action-request-meta.ts#L18-L24Approach
packages/vinext/src/server/app-rsc-handler.tsas the typed runtime owner for App RSC request handling.entries/app-rsc-entry.tsas data and closures passed to the helper.createAppRscHandler.Validation
vp check tests/app-rsc-handler.test.ts packages/vinext/src/server/app-rsc-handler.ts packages/vinext/src/entries/app-rsc-entry.ts tests/app-router.test.ts tests/entry-templates.test.tsvp test run tests/app-rsc-handler.test.ts tests/app-rsc-request-normalization.test.ts tests/app-rsc-response-finalizer.test.ts tests/entry-templates.test.tspassed 68 testsvp test run tests/app-router.test.tspassed 289 testsvp check --fix,tests/entry-templates.test.ts, andknip --no-progressRisks / follow-ups
This PR is stacked on the request-normalization and response-finalizer App RSC refactor work from #1034 and #1035. Until those land or this branch is retargeted, GitHub will show the prerequisite commits in this diff as well.
The remaining generated entry still owns route-specific page/action closures because those depend on generated imports and app shape. That is intentional for this slice.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.