Skip to content

refactor: introduce createAppRscHandler#999

Closed
NathanDrake2406 wants to merge 2 commits intocloudflare:mainfrom
NathanDrake2406:nathan/create-app-rsc-handler
Closed

refactor: introduce createAppRscHandler#999
NathanDrake2406 wants to merge 2 commits intocloudflare:mainfrom
NathanDrake2406:nathan/create-app-rsc-handler

Conversation

@NathanDrake2406
Copy link
Copy Markdown
Contributor

@NathanDrake2406 NathanDrake2406 commented May 1, 2026

Summary

This is stacked on #986

This introduces createAppRscHandler() and moves the top-level App Router RSC request lifecycle out of the generated entry and into a normal typed runtime module.

The generated entry now stays focused on app shape:

  • route/module imports
  • generated manifests and route maps
  • thin closures that describe how to dispatch matched pages, route handlers, and server actions

The runtime helper now owns request behavior:

  • dev origin checks and unified request context setup
  • basePath / trailing-slash normalization
  • prerender endpoints
  • config redirects and rewrites
  • middleware sequencing
  • metadata and public file dispatch
  • server action handoff
  • pages fallback / not-found fallback
  • post-response next.config.js header application

I also trimmed dead surface from the new seam by removing top-level handler options that were not actually consumed there (allowedOrigins, maxActionBodySize). Those remain owned by the action helpers, which is a better fit for the “codegen describes shape, normal modules implement behavior” split.

Why

app-rsc-entry.ts had accumulated too much request orchestration. That made the generated output harder to reason about, harder to test directly, and too easy to grow in the wrong direction.

This refactor keeps codegen responsible for describing the app-specific graph while moving stable behavior into importable runtime code with focused tests.

That layering is closer to how Next.js is structured:

Tests

  • vp check packages/vinext/src/entries/app-rsc-entry.ts packages/vinext/src/server/app-rsc-handler.ts tests/app-rsc-handler.test.ts tests/app-router.test.ts tests/entry-templates.test.ts
  • vp test run tests/entry-templates.test.ts -u
  • vp test run tests/app-rsc-handler.test.ts tests/app-page-dispatch.test.ts tests/entry-templates.test.ts tests/app-router.test.ts tests/app-page-render.test.ts tests/app-page-request.test.ts tests/app-page-cache.test.ts

@NathanDrake2406 NathanDrake2406 force-pushed the nathan/create-app-rsc-handler branch from d164d37 to db09233 Compare May 2, 2026 10:51
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 2, 2026

Open in StackBlitz

npm i https://pkg.pr.new/vinext@999

commit: db09233

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.

1 participant