server hmr and client hmr triggered by a shared module change cause temporary inconsistent render
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- react, typescript, vite
调研方向
首先运行 packages/plugin-rsc/examples/hmr,并检查 App、Item 和共享的 lookup.ts 流程。通过修改 lookup.ts,或同时保存 server 和 client 模块来重现该故障。当 server 和 client 的 HMR 更新能够一致地渲染,且 RSC 响应与 client 代码不会使用不同的模块版本时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Related plugins
Describe the bug
Raising as requested by @hi-ogawa
I've created a reproduction of the issue. The reproduction is where there's a module used on both the client and the server. A change to this shared module throws an error because the server rsc fetch uses the latest version of the module but the client code uses the old version of the module.
There is another way to reproduce the problem without a shared module. Edit a server module and client module at the same time. So make changes to them both without saving individually and then press save all to save them both together.
The problem in a nutshell is that the rsc fetch uses the latest code and the subsequent client render uses the old code.
Reproduction
Steps to reproduce
The App just renders a client Item component passing in a key which It gets from 'lookup.ts'. The Item passes this key into 'lookup.ts' to get the value which it then displays. If you edit the key in 'lookup.ts' from 'a' to 'b', for example, then the hmr update throws.
export const key = 'b'
The reason for the error is that the server response uses the latest 'lookup.ts' but the client uses the old 'lookup.ts'. So the rsc response has the key 'b' but the client still has the key 'a'.
System Info
System:
OS: macOS 14.6.1
CPU: (8) arm64 Apple M1 Pro
Memory: 78.34 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.12.0 - ~/.nvm/versions/node/v22.12.0/bin/node
Yarn: 1.22.22 - /opt/homebrew/bin/yarn
npm: 10.9.0 - ~/.nvm/versions/node/v22.12.0/bin/npm
pnpm: 10.13.1 - ~/.nvm/versions/node/v22.12.0/bin/pnpm
bun: 1.2.5 - ~/.nvm/versions/node/v22.12.0/bin/bun
Watchman: 2024.10.07.00 - /opt/homebrew/bin/watchman
Browsers:
Chrome: 138.0.7204.184
Safari: 17.6
npmPackages:
@vitejs/plugin-react: latest => 4.7.0
@vitejs/plugin-rsc: latest => 0.4.16
vite: ^7.0.4 => 7.0.4
Used Package Manager
npm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
- 主要语言
- TypeScript
- 星标
- 1.2k
- 派生
- 287
- 平均合并
- 1 天 17 小时
- 30 天内合并 PR
- 19
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
vitejs/vite-plugin-react 的其他 Issue
-
plugin-rsc: a client reference's CSS is linked before the CSS of the chunks it imports (build)可能已有人在做 @wozhenbang2004 于 7 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 84/100
vitejs/vite-plugin-react#1570 ·
维护者通常 1 天内回复
-
pending triage
难度 4/5 3-5 天 新手友好度 35/100
vitejs/vite-plugin-react#1581 ·
维护者通常 1 天内回复
-
[plugin-rsc] Build exits 0, but the app fails at runtime: a server action imported only by browser code is missing from the RSC build可能已有人在做 @NeilPant 于 4 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 48/100
vitejs/vite-plugin-react#1578 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 42/100
vitejs/vite-plugin-react#1577 ·
维护者通常 1 天内回复
-
[plugin-rsc] inline "use server" function declarations lose hoisting and throw TDZ ReferenceError可能已有人在做 @draarivpatel-ui 于 2 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 55/100
vitejs/vite-plugin-react#1566 · 1 条评论 ·
维护者通常 1 天内回复
查看 vitejs/vite-plugin-react 的全部 Issue
相似的 Issue
-
good first issue help wanted
难度 2/5 1 小时以内 新手友好度 86/100
Intelligenza-Umana/intelligenza-umana-web#16 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 82/100
open-webui/open-webui#35184 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
danielmiessler/LifeOS#3001 ·
维护者通常 5 天内回复
-
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复