Repository navigation
nav:登录态下 setup 页关闭后无限转圈(effect 死循环)修复 - #18
Merged
todosdev[bot] merged 1 commit intoOct 29, 2026
Merged
Conversation
「登录后补取一次状态」的 effect 只按状态判断(authenticated && phase.kind === "disabled")并在依赖数组里带 phase.kind;refresh 先置 loading、请求回来又落回 disabled,disabled→loading→disabled 往返让 effect 无限重触发,登录态访问 /setup 永远显示「正在检查数据库状态…」。改为只在 anonymous → authenticated 这一次切换上 补取一次(pending → authenticated 属刷新恢复会话,首次取状态已反映该登录态), 并保留「仅在 disabled 形态下重取」的守卫,建号迁移结果不被覆盖。 补 web/test/setup-page.test.tsx 回归覆盖:已登录/未登录 + 关闭态各只请求一次、 登录后补取一次并翻到已初始化形态、恢复会话不重复取、未初始化形态不被刷新覆盖。
This was referenced Nov 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/setup页在已登录 + setup 页面已关闭时无限转圈(一直显示「正在检查数据库状态…」)。根因是 ONE-445 加的「登录后重取一次状态」effect 只按状态判断(authenticated && phase.kind === "disabled")且依赖数组含phase.kind,而refresh()自己会先把形态置回loading、请求回来再落回disabled,disabled → loading → disabled的往返让它无限重触发自己。anonymous → authenticated),因此每次登录最多补取一次、结构上有界;disabled形态守卫原样保留,未初始化形态建号后的迁移结果仍不会被刷新覆盖。/setup的另一种表现(停在「setup 页面已关闭,请登录后在管理面 → 系统管理中开启」)本就正常,同一根因修掉后两者都稳定。后端GET /api/setup/state无改动。Changes
web/src/components/setup/setup-page.tsx— 单文件、+16/−2,不动页面其它部分prevAuthStatusref 记录上一次authStatus,仅在anonymous → authenticated且当前停在disabled形态时调用refresh()。pending → authenticated(刷新恢复会话)不补取:首次GET /api/setup/state已经反映该登录态,再取一次只会让「已关闭」文案闪一下转圈。disabled形态下重取」的守卫,避免把OwnerSetupForm的建号/迁移结果刷掉。web/test/setup-page.test.tsx— 新增 5 个回归用例(此前web/test/下无 setup 页用例)pending → authenticated):不额外请求。范围外未动:无后端、无鉴权/会话、无 schema 或对外契约改动;无
docs/*.md过程文档入库。Testing
pnpm test:worker 9 files / 97 tests passed;web 6 files / 23 tests passed(含新增 5 个)。反向验证:把旧实现临时放回后跑同一测试文件,确认回归能被拦住 ——
已登录 + 关闭用例报expected 1 times, but got 2 times,pending → authenticated用例报Test timed out in 5001ms(陷入死循环);恢复修复版后 5 passed。CI:
ci.yml已在该提交上用workflow_dispatch跑过(run 40843329176),Lint / Format check / Type check / Build / Test 全部 success;lint为 0 error、28 warnings(与改动前基线同为 28)。浏览器实测(本机 Chrome + CDP,夹具托管
web/dist,统计 3 秒窗口内GET /api/setup/state):1440×900 下卡片宽 512px、文档宽 = 视口宽(无横向溢出)。
Tony 只读评审:
Looks good to merge,无 blocking / should-fix。