mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[GH-ISSUE #853] @vitejs/plugin-rsc serverHandler middleware crashes on environment.runner.import when nitro/vite plugin is present #186
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#186
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 @jlucaso1 on GitHub (Apr 16, 2026).
Original GitHub issue: https://github.com/cloudflare/vinext/issues/853
Summary
When
vinextis used together withnitro/vite(as shown in vinext's own setup for deployment), every request to the dev server returns a 500 with:Versions
vinext@0.0.41@vitejs/plugin-rsc@0.5.24vite@8.0.8nitro→nitro-nightly@3.0.1-20260311-140511-1d05f55fv22.22.1, pnpm10.28.2Reproduction
Minimal
vite.config.ts:App with a Next.js App Router layout.
pnpm dev→ any request to/fails.Logs
The same error repeats for every route.
Root cause (as far as I can trace)
@vitejs/plugin-rsc@0.5.24registers aconfigureServermiddleware that does:This path assumes
environmentis aRunnableDevEnvironment. Whennitro/viteis in the plugin chain, nitro's env factory (createFetchableDevEnvironmentinnitro-nightly/dist/vite.mjs) replaces some environments with aFetchableDevEnvironmentsubclass that does not have a.runner— it exposesfetchModule()/devServer.fetchinstead. Soenvironment.runnerisundefinedand the next property access (.import) throws.Elsewhere in plugin-rsc (in the
import.meta.viteRsc.importpath), the code does guard withvite.isRunnableDevEnvironment(environment)before accessing.runner. TheconfigureServermiddleware andconfigurePreviewServerpaths don't have that guard.Interestingly, vinext itself already documents this exact situation in
vinext/dist/server/dev-module-runner.js(comment preserved from source):…and provides a
fetchModule()-based workaround, but that workaround isn't wired into plugin-rsc's own middleware.Impact
With this combination — the combination vinext's own docs recommend for nitro-based deployments — every request in dev returns 500. The app is completely unusable for local development.
Possible fixes
@vitejs/plugin-rscconfigureServer/configurePreviewServer, detect non-runnable environments and fall back toenvironment.fetchModule()(mirroring thevite.isRunnableDevEnvironmentcheck already present elsewhere in the same file).serverHandler: falseto the auto-registeredrsc()plugin when a nitro plugin is detected, and replace it with vinext's ownfetchModule-based handler.Option 2 keeps the fix scoped to this integration and doesn't require a plugin-rsc release.
Workaround
Downgrading
vinextto^0.0.28(which pulls@vitejs/plugin-rsc@^0.5.19, a version without this direct.runner.importcall in its middleware) restores dev.@james-elicx commented on GitHub (Apr 17, 2026):
From what you've written, it sounds like this might be a bug in the RSC plugin - have you tried raising an issue there?