mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 00:09:23 +02:00
[PR #995] fix: warm server action modules in dev #1008
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#1008
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/995
Author: @NathanDrake2406
Created: 4/30/2026
Status: 🔄 Open
Base:
main← Head:nathan/server-action-dev-warmup📝 Commits (2)
a05c187fix: warm server action modules in devc50f5fdchore: 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-rscvalidates incoming server action references against its in-memoryserverReferenceMetaMap. 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 underapp/and add them to the RSC environmentdev.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:
github.com/vercel/next.js@ae61573e06/packages/next/src/build/webpack/loaders/next-flight-client-module-loader.ts (L25-L31)github.com/vercel/next.js@ae61573e06/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:
github.com/vercel/next.js@ae61573e06/packages/next/src/build/webpack/plugins/flight-client-entry-plugin.ts (L1101-L1128)github.com/vercel/next.js@ae61573e06/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:github.com/vercel/next.js@ae61573e06/packages/next/src/server/typescript/utils.ts (L120-L175)Tests
vp test run tests/server-action-warmup.test.tsvp check packages/vinext/src/config/server-action-warmup.ts packages/vinext/src/index.ts tests/server-action-warmup.test.tsvp test run tests/app-server-action-execution.test.tsvp test run tests/app-router.test.ts -t "RSC plugin auto-registration"vp run vinext#buildvp run vinext#buildstill reports the existing virtual-module external warnings forprivate-next-instrumentation-client,virtual:vinext-rsc-entry, andvirtual:vite-rsc/client-references, then exits successfully.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.