[plugin-rsc] Root identity probe triggers mid-request dependency optimization
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- react, typescript, vite
- Ambito
- build-system, devtools
Direzione di ricerca
Start in packages/plugin-rsc/src/plugin.ts around the rsc:virtual-client-package resolver and inspect the second, root-based identity lookup. Reproduce with clean node_modules/.vite and .vinext directories, then run the two curl requests and the focused resolver checks mentioned in the issue. Done means the first request returns 200 without scheduling dependency optimization, while normal resolution and the production build still pass.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Bug
The first cold request to a next-intl app under @cloudflare/vite-plugin returns 500 with Invalid hook call / Cannot read properties of null (reading 'use'). The next request succeeds.
The trigger is the second resolution in rsc:virtual-client-package. The actual import resolves from inside node_modules; the identity check resolves again from <root>/index.html. For root-resolvable transitive dependencies, that second lookup calls Vite's registerMissingImport, causing optimization and a reload during rendering. Here it discovers @formatjs/intl-localematcher, negotiator, @formatjs/fast-memoize, and intl-messageformat.
Reproduction
Application files and configuration are in the downstream report. Use its npm installation, next-intl navigation Link, client translation component, and locale middleware/proxy.
rm -rf node_modules/.vite .vinext
npm run dev # port 3101
From another terminal, without opening the app first:
curl -s -o /dev/null -w '%{http_code}\n' http://localhost:3101/en # 500
curl -s -o /dev/null -w '%{http_code}\n' http://localhost:3101/en # 200
Expected: the first request succeeds; a package-identity check does not schedule dependency optimization.
Tested package patch
This is the exact patch tested against published plugin-rsc 0.5.35, with published vinext unchanged. Save as patches/@vitejs+plugin-rsc+0.5.35.patch for patch-package, or apply with git apply from the app root.
diff --git a/node_modules/@vitejs/plugin-rsc/dist/plugin-CLvIS10V.js b/node_modules/@vitejs/plugin-rsc/dist/plugin-CLvIS10V.js
--- a/node_modules/@vitejs/plugin-rsc/dist/plugin-CLvIS10V.js
+++ b/node_modules/@vitejs/plugin-rsc/dist/plugin-CLvIS10V.js
@@ -1511,17 +1511,26 @@
resolveId: {
order: "pre",
async handler(source, importer, options) {
+ if (options.custom?.["rsc:package-identity-probe"]) return;
if (this.environment.name === serverEnvironmentName && bareImportRE.test(source) && !(source === "client-only" || source === "server-only")) {
const resolved = await this.resolve(source, importer, options);
if (resolved && resolved.id.includes("/node_modules/")) {
const rootImporter = path.join(this.environment.config.root, "index.html");
- let resolvedAtRoot;
+ const scanRoot = this.environment.mode === "dev" && !this.environment.config.optimizeDeps.noDiscovery;
+ let resolvedAtRoot;
try {
- resolvedAtRoot = await this.resolve(source, rootImporter, options);
+ resolvedAtRoot = scanRoot
+ ? await this.environment.pluginContainer.resolveId(source, rootImporter, {
+ ...options,
+ scan: true,
+ custom: { ...options.custom, "rsc:package-identity-probe": true },
+ })
+ : await this.resolve(source, rootImporter, options);
} catch {
return;
}
- if (!resolvedAtRoot || resolvedAtRoot.id !== resolved.id) return;
+ if (!resolvedAtRoot || (resolvedAtRoot.id !== resolved.id &&
+ (!scanRoot || resolvedAtRoot.id !== resolved.id.replace(/\?v=[a-f\d]+$/, "")))) return;
packageSources.set(resolved.id, source);
return resolved;
}
The patch keeps normal import resolution and the root-identity guard, bypasses recursive probes, and tolerates only Vite's terminal version query. Build mode and explicit noDiscovery: true retain the existing path.
Proposed upstream fix: give this diagnostic lookup a supported way to resolve without discovering optimized dependencies. The prototype uses the internal container scan option; passing it to this.resolve() alone does not work because Vite inherits the caller's scan state.
Validation
Four clean starts failed before the patch; all four succeeded after changing plugin-rsc alone. Restoring the package restored the failure. Tested Cloudflare compatibility dates: 2026-09-27 and 2026-02-12. Eight focused resolver checks and a production build also passed; this does not establish browser-hydration or full upstream-suite compatibility.
Versions: macOS arm64, Node 24.21.0, npm, Vite 8.3.1, plugin-rsc 0.5.35, Cloudflare Vite plugin 1.61.0, next-intl 4.14.7, React 19.3.0, vinext 1.0.0-beta.13.
Related: #1273. This identifies a specific trigger for mid-request optimization.
- Lingua principale
- TypeScript
- Stelle
- 1.2k
- Fork
- 287
- Merge medio
- 1g 17h
- PR unite (30g)
- 19
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di vitejs/vite-plugin-react
-
plugin-rsc: a client reference's CSS is linked before the CSS of the chunks it imports (build)Forse già presa @wozhenbang2004 l’ha presa 7 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
vitejs/vite-plugin-react#1570 ·
I maintainer di solito rispondono entro 1 giorno
-
pending triage
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
vitejs/vite-plugin-react#1581 ·
I maintainer di solito rispondono entro 1 giorno
-
[plugin-rsc] Build exits 0, but the app fails at runtime: a server action imported only by browser code is missing from the RSC buildForse già presa @NeilPant l’ha presa 4 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
vitejs/vite-plugin-react#1578 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 42/100
vitejs/vite-plugin-react#1577 ·
I maintainer di solito rispondono entro 1 giorno
-
[plugin-rsc] inline "use server" function declarations lose hoisting and throw TDZ ReferenceErrorForse già presa @draarivpatel-ui l’ha presa 3 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
vitejs/vite-plugin-react#1566 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di vitejs/vite-plugin-react
Issue simili
-
good first issue help wanted
Difficoltà 2/5 Meno di un'ora Idoneità per principianti 86/100
Intelligenza-Umana/intelligenza-umana-web#16 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
open-webui/open-webui#35184 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
danielmiessler/LifeOS#3001 ·
I maintainer di solito rispondono entro 5 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno