Skip to content

test(desktop): TestDebugAnnouncedAdapterThatNeverAnnouncesTimesOut 偶发失败,300ms 启动超时与夹具进程启动竞争 #1962

Done

Description

@xiaoyumuxi

现象

desktop/internal/workbench 的 TestDebugAnnouncedAdapterThatNeverAnnouncesTimesOut(debug_announced_test.go,#1954 引入)偶发失败:

=== RUN   TestDebugAnnouncedAdapterThatNeverAnnouncesTimesOut
    debug_announced_test.go:269: the adapter process never connected to the watch
--- FAIL: TestDebugAnnouncedAdapterThatNeverAnnouncesTimesOut (20.43s)
  • 平台:macOS arm64,scripts/desktop/desktop-go.sh test ./internal/workbench -count=1 整包运行时出现;单独 -run 'TestDebugAnnounced' -count=3 也是 3 次失败 1 次。
  • 在 Viva 上游同步分支(基于 preview c6cdf26af)验证时发现,该分支没有改动 debug 代码。

原因

测试把 debugInitializeWindow 设为 300ms。夹具适配器是重新执行的测试二进制(链接 Rust Core),它先拨号 watch 再打印 started。负载下进程启动超过 300ms 时,宿主的启动超时先触发并结束进程,进程从未连上 watch;announcedWatch.ended 于是等满 20 秒后失败。测试断言“超时后进程被停止”本身成立,失败的是用 watch 连接证明“进程曾运行”这一步与超时计时器竞争。

期望

按 write-stable-tests 的确定性时间规则,让超时不依赖真实进程的启动速度,例如:

  • 测试先等夹具连上 watch(进程确已运行),再触发启动超时(给 watchDebugInitialize 一个测试可控的触发点,而不是固定 300ms);或
  • ended 在进程未连上 watch 时,改用宿主持有的进程句柄确认进程已退出。

同文件其他用 watch 的测试一并检查。

Activity

  1. added
    review: high
    on Nov 15, 2026
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

    review: high

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions