Skip to content

CI 偶发:bot-runner 真 Chrome 截图用例 captureScreenshot 30 秒不回 #89

Open

Description

@joesmart

从 #79 拆出来。#79 的另一条(电脑代理「stdin 关闭后停机」)由 #88 修掉,这条单独跟。

现象

packages/bot-runner/test/runner.test.ts「助理浏览器(真 Chrome)> 截图进模型是图片,截的时候密码框是空的,截完填回去」在 CI 上偶尔红。两次失败都是 Page.captureScreenshot 30 秒不回:

  • main push,run 39767590315
  • PR,run 39564987085

重跑能过。

已经查过的

在 CI 上临时加了探针,照搬 ci.yml 的 chromium、AppArmor 和 Xvfb 配置,跑了 48 轮(空闲 24 轮,加负载 24 轮),一次都没卡住:

  • 标签页一直是 visible true 780x493
  • captureScreenshot 每次 43–94ms
  • 整条用例空闲时约 350ms,加负载时 7.5–10s,慢的地方都不在截图

最可能的根因(未证实)

headless Chromium 在 CI 满载时截图偶尔卡住。没复现,也没证据,所以 #88 没改代码,也没调超时。

下一步可以做的

  • 再红的时候,把 Chrome 的 stderr 和失败瞬间的 Target.getTargets 留下来,看页面当时的状态
  • 或者给 captureScreenshot 包一层诊断,超时时打出页面的 visibility 和 lifecycle

🤖 Generated with Claude Code

https://claude.ai/code/session_01Be3SZps2JjqvyrJ1vbLmni

Activity

  1. joesmart commented on Oct 23, 2026

    @joesmart
    ContributorAuthor

    补一条同类问题:在最终 main(c6f262d)上跑 pnpm check,packages/bot-runner/test/x-publisher.test.ts 的 8 条用例全过,但 afterAll 里 rmSync(profileDir, { recursive: true, force: true }) 报 ENOTEMPTY, Directory not empty: .../baize-x-publisher-chrome-*,整个文件被判红。单独重跑 3 次全绿。

    推测(未证实):chrome.stop() 返回后,Chrome 的子进程还在往配置目录里写文件。可以给 rmSync 加上 maxRetries,或者等 Chrome 的进程组全部退出后再删目录。

    🤖 Generated with Claude Code

    https://claude.ai/code/session_01Be3SZps2JjqvyrJ1vbLmni

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