pi-model-auto-router: 修复 stall watchdog 竞态(iterator.return 不解除挂起的 next()) #16

Merged
weisanju merged 1 commit from fix/stall-watchdog-race into main 2026-09-22 20:53:41 +08:00
weisanju commented 2026-09-22 20:53:25 +08:00 (Migrated from github.com)

Summary

  • PR #12 的 stall failover 存在竞态:pi-ai 底层迭代器的 return() 不会让挂起的 next() 返回,watchdog 触发后 for-await 循环永远卡死,post-loop failover 代码无法执行,导致发布 CI 的测试门禁拦截 v0.4.0
  • 新增 loopInterrupted promise + wakeLoop():abort / watchdog 终结时唤醒消费循环(Promise.race([pendingNext, loopInterrupted])),吞掉迟到的迭代结果后退出,由 ended.done / stalledByWatchdog 决定 transient failover 或 abort 清理
  • 修正 e2e 断言:冷却警示(⚠ target ✗剩余时长)优先于 last=failed 是既定展示优先级,改为断言两目标进入冷却 + all-failed 错误事件

Test plan

  • bun run check 通过
  • bun test 31/31(含原失败的 stalled-stream failover 测试)
  • bun run build 重建 dist
  • 合并后重打 pi-model-auto-router/v0.4.0 标签,发布 CI 全绿
## Summary - PR #12 的 stall failover 存在竞态:pi-ai 底层迭代器的 `return()` 不会让挂起的 `next()` 返回,watchdog 触发后 for-await 循环永远卡死,post-loop failover 代码无法执行,导致发布 CI 的测试门禁拦截 v0.4.0 - 新增 `loopInterrupted` promise + `wakeLoop()`:abort / watchdog 终结时唤醒消费循环(`Promise.race([pendingNext, loopInterrupted])`),吞掉迟到的迭代结果后退出,由 `ended.done` / `stalledByWatchdog` 决定 transient failover 或 abort 清理 - 修正 e2e 断言:冷却警示(`⚠ target ✗剩余时长`)优先于 `last=failed` 是既定展示优先级,改为断言两目标进入冷却 + all-failed 错误事件 ## Test plan - [x] `bun run check` 通过 - [x] `bun test` 31/31(含原失败的 stalled-stream failover 测试) - [x] `bun run build` 重建 dist - [ ] 合并后重打 `pi-model-auto-router/v0.4.0` 标签,发布 CI 全绿
Sign in to join this conversation.
No description provided.