- 归档 OnlyOffice live bridge、Page AI、mindmap、design governance 与相关 bug 条目 - 补齐 MinerU OCR 后端 runtime 合同与 smoke/test 基线 - 收口 ChatOnly/Doubao、ObjectIdentity、Page Aggregate compat 与 runtime owner 文档口径 验证: - cargo test --manifest-path rust/Cargo.toml -p mnote-web local_ocr -- --test-threads=1 - cargo test --manifest-path rust/Cargo.toml -p mnote-web onlyoffice_bridge -- --test-threads=1 - git diff --check - git diff --cached --check - codegraph index . --force && codegraph status . - codegraph sync . && codegraph status .
2.6 KiB
2.6 KiB
3-26 Sidebar dev hot reload 在主 runtime 中使用 setInterval
状态
- 状态:done
- Owner:03-rust-web / browser runtime
- 发现时间:2026-05-31
现象
sidebar-tree-runtime.js 在主 Sidebar runtime 中安装 dev hot reload,并无前置环境 guard 地执行 window.setInterval(tick, 1000)。项目架构约束要求浏览器主链默认禁止新增基于 setInterval、周期 setTimeout 或轮询 fallback 的数据刷新和状态同步;即使这是 dev hot reload,也应该显式限制在 debug/dev 边界。
证据
rust/crates/mnote-web/browser/sidebar-tree-runtime.js中installMnoteDevHotReload()执行:- 先调用
tick()。 - 再执行
timer = window.setInterval(tick, 1000)。 - 末尾无条件调用
installMnoteDevHotReload()。
- 先调用
tick()每次请求/api/dev/hot-reload,服务端返回enabled !== true时才清理 timer;这仍意味着页面启动后先进入轮询逻辑。
影响
- 主 Sidebar runtime 默认携带 dev 轮询逻辑,和“主链不叠加轮询 fallback”的架构约束冲突。
- 若
/api/dev/hot-reload异常或返回形态变化,可能引入重复请求、console 噪音或性能误判。 - 后续 worker 可能把这种模式复制到其他可见路径。
修复建议
- 在 Rust SSR bootstrap 中显式注入 dev/hot 模式标记,只有 dev hot 模式启用时才安装该逻辑。
- 或将 hot reload 逻辑迁到 debug/internal runtime,不放在默认 Sidebar runtime。
- 如果仍保留定时器,必须在设计/注释中说明退出条件和边界,并保证生产/普通 desktop 模式不可达。
本轮进展
- 2026-05-31:
sidebar-tree-runtime.js已改为通过import.meta.url检查当前模块 URL 是否携带devHotcache buster;只有 dev hot 模式才安装 hot reload 轮询。- 已补
layout.rs静态断言,禁止无条件installMnoteDevHotReload()回流。 - 已通过
node --check rust/crates/mnote-web/browser/sidebar-tree-runtime.js和 Rust 定点测试。 - 已补
scripts/task514-sidebar-dev-hot-reload-gating-smoke.js固化真实浏览器验证。 - 验证通过:
node scripts/task514-sidebar-dev-hot-reload-gating-smoke.js。结果显示普通入口hotReloadRequestCount=0、scriptHasDevHot=false;hot 模式scriptHasDevHot=true、hotReloadRequestCount=2、data-mnote-dev-hot-reload=enabled,且无 console/network 错误。
验收
- 普通
desktop/ 非 hot 入口打开后,浏览器不会请求/api/dev/hot-reload。 npm run desktop:hot或等价 hot 模式下仍能刷新。setInterval(tick, 1000)仅在mnoteDevHotReloadEnabled()guard 后可达。