【CI flaky】CreatorPages「回关/取消关注」用例在并发负载下点击被吞,导致 Frontend tests 偶发失败 #644
Reference in New Issue
Block a user
Delete Branch "%!s()"
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?
1. 现象
CI run 3548(head
f0cad9ddd,PR #635)的Frontend testsattempt 1 失败:重跑同一 job(attempt 2)全绿(2925 passed / 254 files),坐实 flaky。
2. 根因(已取证,含机理与文件行号)
src/components/creator/hooks/useCreatorRelationship.ts的 effect 完成。value仍为null」的那一帧,按钮为disabled=true(src/components/creator/controls/CreatorRelationshipControl.tsx:34-37),但按钮文本已经是「回关」(followed默认 false)→findByRole('回关')会在这一帧就命中。onClick→fireEvent.click被吞(实测 onClick 命中 0 次),写入从未发生;随后 store 才 seed,按钮保持「回关」,CreatorPages.test.tsx:145永远等不到「取消关注」。findBy超时无效:该帧之后 DOM 不会再变化。setTimeout(0)、React scheduler 先 flush;只有 CPU 严重超卖(CI runner 上 5 个 job 并发)时才会带着首帧 DOM 继续执行。3. 复现数据
4. 归属
src/components/creator/**与packages/shared/src/components/CreatorControls在 master tip52c83cc2a与失败 headf0cad9ddd之间 diff 为空,来自已并入 master 的 PR #638;与本 PR #635 无关。5. 最小修法
仓库内已有同款先例:
src/components/game-distribution/GameDistributionPages.test.tsx:262-271(先等 disabled 变 false 再点)。6. 无效替代方案
findByRole默认 1s 超时提到 5s(DOM 不再变化,等多久都无用);api.write被调用(写入根本不会发生);7. 影响面
会让任何 PR 的
Frontend tests随机变红,需要人工重跑,浪费 CI 时长与排查成本。8. 验证计划
test:ci:frontend绿。