[PR #995] fix: warm server action modules in dev #1008

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

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/995
Author: @NathanDrake2406
Created: 4/30/2026
Status: 🔄 Open

Base: mainHead: nathan/server-action-dev-warmup


📝 Commits (2)

  • a05c187 fix: warm server action modules in dev
  • c50f5fd chore: rerun ci

📊 Changes

3 files changed (+403 additions, -0 deletions)

View changed files

packages/vinext/src/config/server-action-warmup.ts (+168 -0)
📝 packages/vinext/src/index.ts (+22 -0)
tests/server-action-warmup.test.ts (+213 -0)

📄 Description

Summary

Fixes #994.

In dev, @vitejs/plugin-rsc validates incoming server action references against its in-memory serverReferenceMetaMap. That map is populated when action modules are transformed, so a cold action POST can fail before the action file has been loaded. This PR has vinext discover module-level "use server" files under app/ and add them to the RSC environment dev.warmup, preserving any user-specified warmup entries.

The behavior is intentionally implemented in a normal config helper instead of expanding generated entries: codegen continues to describe the app shape, while runtime/config behavior lives in importable modules.

Next.js reference behavior

Next.js does not rely on first-request lazy module transforms to recognize server actions. The webpack client module loader identifies server action IDs from RSC module metadata and proxies them in production:

Next also builds action assets and emits the server action manifest from discovered action entries, rather than waiting for the first action request to discover the module:

For directive semantics, the warmup scanner follows Next.js's module directive model: only directive-prologue string literals count, so inline "use server" actions are not treated as module-level server action files. Reference:

Tests

  • vp test run tests/server-action-warmup.test.ts
  • vp check packages/vinext/src/config/server-action-warmup.ts packages/vinext/src/index.ts tests/server-action-warmup.test.ts
  • vp test run tests/app-server-action-execution.test.ts
  • vp test run tests/app-router.test.ts -t "RSC plugin auto-registration"
  • vp run vinext#build

vp run vinext#build still reports the existing virtual-module external warnings for private-next-instrumentation-client, virtual:vinext-rsc-entry, and virtual:vite-rsc/client-references, then exits successfully.


🔄 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/995 **Author:** [@NathanDrake2406](https://github.com/NathanDrake2406) **Created:** 4/30/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `nathan/server-action-dev-warmup` --- ### 📝 Commits (2) - [`a05c187`](https://github.com/cloudflare/vinext/commit/a05c187890ce9ba3638401b5aae3b3e40a9dd77a) fix: warm server action modules in dev - [`c50f5fd`](https://github.com/cloudflare/vinext/commit/c50f5fdf51c976362b106573c2a33093c253f11a) chore: rerun ci ### 📊 Changes **3 files changed** (+403 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `packages/vinext/src/config/server-action-warmup.ts` (+168 -0) 📝 `packages/vinext/src/index.ts` (+22 -0) ➕ `tests/server-action-warmup.test.ts` (+213 -0) </details> ### 📄 Description ## Summary Fixes #994. In dev, `@vitejs/plugin-rsc` validates incoming server action references against its in-memory `serverReferenceMetaMap`. That map is populated when action modules are transformed, so a cold action POST can fail before the action file has been loaded. This PR has vinext discover module-level `"use server"` files under `app/` and add them to the RSC environment `dev.warmup`, preserving any user-specified warmup entries. The behavior is intentionally implemented in a normal config helper instead of expanding generated entries: codegen continues to describe the app shape, while runtime/config behavior lives in importable modules. ## Next.js reference behavior Next.js does not rely on first-request lazy module transforms to recognize server actions. The webpack client module loader identifies server action IDs from RSC module metadata and proxies them in production: - https://github.com/vercel/next.js/blob/ae61573e062e900050b8e6b24626e450accc4570/packages/next/src/build/webpack/loaders/next-flight-client-module-loader.ts#L25-L31 - https://github.com/vercel/next.js/blob/ae61573e062e900050b8e6b24626e450accc4570/packages/next/src/build/webpack/loaders/next-flight-client-module-loader.ts#L31-L40 Next also builds action assets and emits the server action manifest from discovered action entries, rather than waiting for the first action request to discover the module: - https://github.com/vercel/next.js/blob/ae61573e062e900050b8e6b24626e450accc4570/packages/next/src/build/webpack/plugins/flight-client-entry-plugin.ts#L1101-L1128 - https://github.com/vercel/next.js/blob/ae61573e062e900050b8e6b24626e450accc4570/packages/next/src/build/webpack/plugins/flight-client-entry-plugin.ts#L1130-L1158 For directive semantics, the warmup scanner follows Next.js's module directive model: only directive-prologue string literals count, so inline `"use server"` actions are not treated as module-level server action files. Reference: - https://github.com/vercel/next.js/blob/ae61573e062e900050b8e6b24626e450accc4570/packages/next/src/server/typescript/utils.ts#L120-L175 ## Tests - `vp test run tests/server-action-warmup.test.ts` - `vp check packages/vinext/src/config/server-action-warmup.ts packages/vinext/src/index.ts tests/server-action-warmup.test.ts` - `vp test run tests/app-server-action-execution.test.ts` - `vp test run tests/app-router.test.ts -t "RSC plugin auto-registration"` - `vp run vinext#build` `vp run vinext#build` still reports the existing virtual-module external warnings for `private-next-instrumentation-client`, `virtual:vinext-rsc-entry`, and `virtual:vite-rsc/client-references`, then exits successfully. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#1008
No description provided.