Skip to content

refactor: introduce createAppRscHandler#5

Closed
NathanDrake2406 wants to merge 1 commit into
nathan/extract-app-page-dispatchfrom
nathan/create-app-rsc-handler
Closed

refactor: introduce createAppRscHandler#5
NathanDrake2406 wants to merge 1 commit into
nathan/extract-app-page-dispatchfrom
nathan/create-app-rsc-handler

Conversation

@NathanDrake2406

Copy link
Copy Markdown
Owner

Summary

This is stacked on cloudflare#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

Copilot AI review requested due to automatic review settings May 1, 2026 09:47
@NathanDrake2406
NathanDrake2406 marked this pull request as draft May 1, 2026 09:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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.

2 participants