[PR #967] [MERGED] refactor: extract server action RSC flow #988

Closed
opened 2026-05-06 13:11:24 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/967
Author: @NathanDrake2406
Created: 4/29/2026
Status: Merged
Merged: 4/29/2026
Merged by: @james-elicx

Base: mainHead: nathan/extract-server-action-rsc-flow


📝 Commits (1)

  • 6e1899a refactor: extract server action rsc flow

📊 Changes

6 files changed (+1276 additions, -1617 deletions)

View changed files

📝 packages/vinext/src/entries/app-rsc-entry.ts (+84 -221)
📝 packages/vinext/src/server/app-server-action-execution.ts (+353 -2)
📝 tests/__snapshots__/entry-templates.test.ts.snap (+504 -1326)
📝 tests/app-router.test.ts (+43 -54)
📝 tests/app-server-action-execution.test.ts (+281 -0)
📝 tests/entry-templates.test.ts (+11 -14)

📄 Description

Summary

Extract the fetch/RSC server action POST flow out of the generated App Router RSC entry and into packages/vinext/src/server/app-server-action-execution.ts.

The generated entry now describes app shape and route-specific wiring only: action headers, route matching, element construction, request-scoped callbacks, and route table access. The normal server module owns behavior: CSRF checks, body limits, payload validation, action execution phase, redirect control headers, action return packaging, middleware/cookie header merging, and RSC response construction.

Next.js references

  • Next.js centralizes app server action handling in handleAction.
  • Next.js classifies fetch actions by the next-action header in getServerActionRequestMetadata.
  • Next.js separates MPA action decoding/fallthrough from fetch action decoding in action-handler.ts.
  • Next.js executes the action, then generates Flight/RSC output for fetch actions in action-handler.ts.
  • Next.js keeps redirect and thrown-error handling in the action module, including redirect-as-client-router result and rejected action result Flight generation: action-handler.ts.

Tests

  • vp test run tests/app-server-action-execution.test.ts tests/entry-templates.test.ts
  • vp test run tests/app-router.test.ts -t "server action"
  • vp check

Notes

This is intentionally a refactor of ownership, not a behavior change. Existing generated-entry assertions that locked down inline action implementation were moved to helper-focused behavior tests and generated-entry wiring tests.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cloudflare/vinext/pull/967 **Author:** [@NathanDrake2406](https://github.com/NathanDrake2406) **Created:** 4/29/2026 **Status:** ✅ Merged **Merged:** 4/29/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `nathan/extract-server-action-rsc-flow` --- ### 📝 Commits (1) - [`6e1899a`](https://github.com/cloudflare/vinext/commit/6e1899a445ec75999872778713e327ba3234fc07) refactor: extract server action rsc flow ### 📊 Changes **6 files changed** (+1276 additions, -1617 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/entries/app-rsc-entry.ts` (+84 -221) 📝 `packages/vinext/src/server/app-server-action-execution.ts` (+353 -2) 📝 `tests/__snapshots__/entry-templates.test.ts.snap` (+504 -1326) 📝 `tests/app-router.test.ts` (+43 -54) 📝 `tests/app-server-action-execution.test.ts` (+281 -0) 📝 `tests/entry-templates.test.ts` (+11 -14) </details> ### 📄 Description ## Summary Extract the fetch/RSC server action POST flow out of the generated App Router RSC entry and into `packages/vinext/src/server/app-server-action-execution.ts`. The generated entry now describes app shape and route-specific wiring only: action headers, route matching, element construction, request-scoped callbacks, and route table access. The normal server module owns behavior: CSRF checks, body limits, payload validation, action execution phase, redirect control headers, action return packaging, middleware/cookie header merging, and RSC response construction. ## Next.js references - Next.js centralizes app server action handling in [`handleAction`](https://github.com/vercel/next.js/blob/e1bb911c14e4ea3c6bb8cc98871ffdee317d513f/packages/next/src/server/app-render/action-handler.ts#L529-L545). - Next.js classifies fetch actions by the `next-action` header in [`getServerActionRequestMetadata`](https://github.com/vercel/next.js/blob/e1bb911c14e4ea3c6bb8cc98871ffdee317d513f/packages/next/src/server/lib/server-action-request-meta.ts#L18-L43). - Next.js separates MPA action decoding/fallthrough from fetch action decoding in [`action-handler.ts`](https://github.com/vercel/next.js/blob/e1bb911c14e4ea3c6bb8cc98871ffdee317d513f/packages/next/src/server/app-render/action-handler.ts#L984-L1044). - Next.js executes the action, then generates Flight/RSC output for fetch actions in [`action-handler.ts`](https://github.com/vercel/next.js/blob/e1bb911c14e4ea3c6bb8cc98871ffdee317d513f/packages/next/src/server/app-render/action-handler.ts#L1128-L1170). - Next.js keeps redirect and thrown-error handling in the action module, including redirect-as-client-router result and rejected action result Flight generation: [`action-handler.ts`](https://github.com/vercel/next.js/blob/e1bb911c14e4ea3c6bb8cc98871ffdee317d513f/packages/next/src/server/app-render/action-handler.ts#L1178-L1278). ## Tests - `vp test run tests/app-server-action-execution.test.ts tests/entry-templates.test.ts` - `vp test run tests/app-router.test.ts -t "server action"` - `vp check` ## Notes This is intentionally a refactor of ownership, not a behavior change. Existing generated-entry assertions that locked down inline action implementation were moved to helper-focused behavior tests and generated-entry wiring tests. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:11:24 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#988
No description provided.