Skip to content

test(workflow): workflow-node-daemon 首段 describe 两处 setTimeout(10) 等通知仍是时序竞态(#2824 遗留) #2829

Closed

Description

@deepcoldy

背景

#2824 把 test/workflow-node-daemon.test.ts 里 second-review-pass 与 §15.4 两个 describe 的固定睡眠统一换成了 eventually(() => vi.waitFor(assertion,{timeout:10s,interval:10ms})),但第一个 describe「workflow node daemon wiring」里还有两处内联 await new Promise(r=>setTimeout(r,10)) 没扫到:

  • 约 :211「registration and the handoff turn's idle notify the main bot; a submitted handoff stays quiet」
  • 约 :224「P3-8: only the handoff's own turn can stall it; a later turn starting reports the bot active again」

两处都是同步触发 onRegistered/onTurnSettled/onInputCommitted 后等 fire-and-forget notify(accepted/stalled/active 经 postDaemon 发出),再断言 target.posted。

触发条件(Pure(pi) 探针)

  • 只给 recordWorkflowHandoffRefusal 加 300ms 延迟:32/32 绿(这两处不经该链路)。
  • 同时把该用例的内存 fake postDaemon 拖到 250ms:2 条红(expected [] to equal ['accepted','stalled'] / ['active','accepted'])。
  • 把同样双压施加到上游 b979419 本身(不含任何其它 PR):同样 2 条红——确认是 fix(test): workflow-node-daemon 用例等到后台通知结束再断言 #2824 范围遗留,非引入回归。

fake postDaemon 是内存调用,CI 现实中很少慢到 250ms,故为低概率 P3,不阻断任何在途 PR。

建议修法

与 #2824 同源、机械:两处 setTimeout(10) 换成 await eventually(() => expect(target.posted.map(p=>p.body.kind)).toEqual([...]))(eventually 已在该文件顶部定义),并补「拖慢 postDaemon 后不等待即红、等待即绿」的变异确认。

自动评审记录,来自 #2806 双审过程(最终以维护者判断为准)。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions