Run React Refresh at vite:afterUpdate instead of after a fixed 16 ms
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 45/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- react, typescript, vite
- 领域
- build-system, frontend
调研方向
Start in packages/common/refresh-runtime.js, where enqueueUpdate is a debounce with a 16 ms delay that runs the hooks and then performReactRefresh. Look at how the client emits vite:afterUpdate and where validateRefreshBoundaryAndEnqueueUpdate is called. Done means flushing the pending refresh on vite:afterUpdate while the timer still covers enqueues outside an update. Check the timing in the existing refresh tests.
由索引模型根据 Issue 内容生成。
描述
Drafted with an AI assistant (Claude), reviewed by me.
Related plugins
- plugin-react
Description
React Refresh runs 16 ms after the last accepted module (packages/common/refresh-runtime.js, 6.3.0):
const enqueueUpdate = debounce(async () => {
if (hooks.length) await Promise.all(hooks.map((cb) => cb()))
performReactRefresh()
}, 16)
So every Fast Refresh edit waits at least 16 ms after its modules have run.
We see it in TanStack Router, which waits for the pass through __registerBeforePerformReactRefresh before applying a route edit: an edit of only a route's loader went from 16.9 to 36.8 ms save-to-DOM when we started waiting (1,485-route app).
Suggested solution
By the time the client emits vite:afterUpdate, every module of the payload has run its accept callback, so every validateRefreshBoundaryAndEnqueueUpdate call of that update has been made. Flush there, and keep the timer for enqueues outside an update:
import.meta.hot.on('vite:afterUpdate', () => flushPendingRefresh())
Alternative
Keep the debounce but expose a way to flush it.
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines
- Read the docs
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate
- 主要语言
- 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 于 6 天前认领。 未关闭
难度 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 于 3 天前认领。 未关闭
难度 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
-
难度 2/5 1-3 小时 新手友好度 67/100
knaw-huc/textannoviz#742 ·
-
难度 2/5 1-3 小时 新手友好度 88/100
cloudflare/realtimekit-ui#219 ·
维护者通常 1 天内回复
-
ui
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
tui: Mermaid renderer displays <b>/<strong> tags literally and ignores \n line breaks可能已有人在做 @argszero 今天认领。 未关闭area/tui platform/wsl status/repro-simulated type/bug version/v2
难度 2/5 1-3 小时 新手友好度 82/100
anomalyco/opencode#66773 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
mermaid-js/mermaid-v13#1370 ·
维护者通常 1 天内回复