[plugin-rsc] vite build --watch exits 1 with ENOENT before the first build is written

Đang mở
#1,577 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
42/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
node.js, react, typescript, vite
Lĩnh vực
build-system, tooling

Hướng nghiên cứu

Start in packages/plugin-rsc/src/plugin.ts around the buildApp calls (the issue points at L496-L505 and L524) and read how the builder's return value is used: under build.watch the promise resolves with a watcher, not finished output, so the subsequent rename and manifest write race the first build. Reproduce first with the linked repro repo (npm run repro vs npm run control) across both output layouts. Done means vite build --watch produces the same files as vite build and keeps watching; a regression test in the plugin's test suite should cover both layouts.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Written with the help of an AI coding agent (Claude); reproduced locally.

Related plugins
Describe the bug

vite build --watch with plugin-rsc exits 1 on the first build and writes no server entry. vite build with the same config works.

Default output layout:

[5/5] build ssr environment...
vite v8.3.8 building ssr environment for production...

watching for file changes...
error during build:
Error: ENOENT: no such file or directory, open '<root>/dist/ssr/__vite_rsc_assets_manifest.js'
    at RscPluginManager.writeAssetsManifest (.../@vitejs/plugin-rsc/dist/plugin-Ct0hu_Ip.js:626:7)
    at buildApp (.../@vitejs/plugin-rsc/dist/plugin-Ct0hu_Ip.js:741:11)

With the RSC output inside the SSR output (rsc: dist/server/rsc, ssr: dist/server) it fails at step 3:

[3/5] build rsc environment...
vite v8.3.8 building rsc environment for production...

watching for file changes...
error during build:
Error: ENOENT: no such file or directory, rename '<root>/dist/server/rsc' -> '<root>/node_modules/.vite-rsc-temp/rsc'
    at buildApp (.../@vitejs/plugin-rsc/dist/plugin-Ct0hu_Ip.js:729:7)

Under build.watch, builder.build() resolves with the watcher before the output is written, and buildApp moves or writes into it right away:
https://github.com/vitejs/vite-plugin-react/blob/447ab6208f5fd85968e8307735e1198ea17148c2/packages/plugin-rsc/src/plugin.ts#L496-L505
(and L524 for the manifest).

Reproduction

https://github.com/Sheraff/vite-plugin-rsc-build-watch-repro

Steps to reproduce
npm install
npm run repro    # vite build --watch on both layouts
npm run control  # vite build on both layouts

Actual:

$ npm run repro
BUG default layout  exit 1
    missing: dist/rsc/index.js, dist/ssr/index.js
    Error: ENOENT: no such file or directory, open 'dist/ssr/__vite_rsc_assets_manifest.js'
BUG rsc inside ssr  exit 1
    missing: dist/server/rsc/index.js, dist/server/index.js
    Error: ENOENT: no such file or directory, rename 'dist/server/rsc' -> 'node_modules/.vite-rsc-temp/rsc'

$ npm run control
OK  default layout  exit 0
OK  rsc inside ssr  exit 0

Expected: vite build --watch writes the same output as vite build and keeps watching.

Same result on vite 8.3.4, 8.4.0-beta.1 and 7.3.8, and with the pkg.pr.new build of main (447ab62).

System Info
  System:
    OS: Linux 6.12 Debian GNU/Linux 13 (trixie) 13 (trixie)
    CPU: (32) x64 AMD Ryzen 9 9955HX 16-Core Processor
    Memory: 53.06 GB / 60.50 GB
    Container: Yes
    Shell: 5.2.37 - /bin/bash
  Binaries:
    Node: 26.12.1 - ~/.local/share/pnpm/bin/node
    npm: 12.2.0 - ~/.local/share/pnpm/bin/npm
    pnpm: 12.11.2 - ~/.local/share/pnpm/bin/pnpm
  Browsers:
    Chrome: 158.0.8127.36
  npmPackages:
    @vitejs/plugin-rsc: 0.5.39 => 0.5.39
    react: 19.3.1 => 19.3.1
    react-dom: 19.3.1 => 19.3.1
    vite: 8.3.8 => 8.3.8
Used Package Manager

npm

Validations
Ngôn ngữ chính
TypeScript
Star
1.2k
Fork
287
Merge trung bình
1 ngày 17 giờ
Pull request đã merge (30 ngày)
19

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của vitejs/vite-plugin-react

Tất cả issue của vitejs/vite-plugin-react

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.