fix(router): 补回 BinReplenishMonitor 的 lazy 声明,修复生产全站白屏 #77
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "codex/hotfix-bin-replenish-lazy-20261022"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
故障现象
生产
https://ck.yydd.ai:8443打开任意页面都是白屏,连/login都进不去 —— 用户反馈「真实环境的页面登录不上」。用真实浏览器(playwright)打开目标页面取证:
根因
PR #74 新增「缺货补货监控」时,在
frontend/src/router/index.jsx的路由表里写了:但没有像其它 22 个页面那样在文件顶部补 lazy 声明。该表在模块顶层求值 →
加载 router 即抛
ReferenceError→ 整个 React 应用挂掉 → 全站白屏。vite build拦不住:未声明标识符在 JS 里是合法语法,构建一路绿灯,部署后才发现。线上与 main 都中招:
const BinReplenishMonitor = lazy(55b755corigin/main03fd3f9PR #75(
a15f289「补回 binReplenishRoutes 引入,修复后端启动失败」)只修了后端的路由引入,前端的这处漏声明一直没人发现。
改动
frontend/src/router/index.jsx:补回 lazy 声明,并加注释点明「漏一个 = 全站白屏」。frontend/scripts/verify-router-lazy.mjs(新增):静态扫描 router/index.jsx,凡被
renderLazyComponent(X)使用的 X,必须在同文件有const X = lazy(声明,否则构建直接失败并报出缺少的组件名与行号。
frontend/package.json:把该检查挂到npm run build前置,并加verify:router-lazy单独入口。验证
① 检查脚本有效性(对未修复的 origin/main 版本)
修复后:
Verified router lazy declarations: 23 used, 23 declared→exit=0② 构建与 lint:eslint 无告警;
vite build成功(4270 modules / 34.15s)③ playwright 真渲染(本地 5173 + 后端 4002)
/loginBinReplenishMonitor is not defined/planning/operation/warehouse-logistics-exception/planning/operation/bin-replenish-monitor影响面
只补一行声明 + 新增构建检查,不改任何业务逻辑与接口。合并后需重新构建并部署才能解除生产白屏。