mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[GH-ISSUE #994] Server actions fail with [vite-rsc] invalid server reference on cold-start in dev #217
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#217
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?
Originally created by @eashish93 on GitHub (Apr 30, 2026).
Original GitHub issue: https://github.com/cloudflare/vinext/issues/994
Repro: App Router project, 'use client' component statically imports a 'use server' action, action invoked before browser has fetched the action file (e.g. dev-server restart while browser kept stale modules, or any race where the action call lands first).
Cause: @vitejs/plugin-rsc populates serverReferenceMetaMap lazily as files are transformed. Validation runs before the lazy import that would trigger the transform, so cold validation throws [vite-rsc] invalid server reference '/path/to/action.ts' and the action never runs. Tracked upstream as #641.
Workaround (in user's vite.config.ts):
Suggested fix: vinext could auto-inject dev.warmup for any file under app/ (and configurable action dirs) containing 'use server'.
Since vinext already scans for App Router files, adding 'use server' detection during that scan is cheap. Users wouldn't need any config.