Skip to content

Windows CI lane-decisions-matrix 偶发 teardown 挂起(Promise 未决但事件循环已空),随机把 PR 打红 #3602

Closed

Description

@ranxianglei

来源: PR #3595 (#3595) 分析其 windows CI 失败时发现

查重: 无 — open/closed issues 按 "windows flake"、"listen close"、"lane-decisions"、"event loop has already resolved" 检索均无在途跟踪项;最接近的前置工作是已合入的 #3490 加固 commit aa56257,本 issue 是该加固的残余变体,非重复。

现象

PR #3595 head e8fdea0 的 run 39046129274 中,test (windows-latest, 22, 1)(job 117435166799,node v22.23.3 win32/x64)失败:

  • 首个 not-ok 为 lane matrix [google] dsh no-tools drops the surface (#3177)(tests/lane-decisions-matrix.test.ts,ok-number 1539,duration_ms≈4986),failureType: 'cancelledByParent',error 为 'Promise resolution is still pending but the event loop has already resolved';
  • 其后 5 个兄弟子测试被级联取消(duration 0),TAP 汇总 # pass 4170 / # fail 0 / # cancelled 6,exit=1;
  • ci-tests harness 判定该失败「带具体断言信息」不做自动重试 → 整个 shard 红。

同 run 其余全部 lane 绿;master HEAD b10c525 的全量 run(含所有 windows shard)也全绿 → 间歇性 flake,与触发它的 PR diff(纯错误文案变更,不触碰该测试路径)无关。

影响

随机把任意 PR 的某个 windows shard 打红、阻塞合并。重跑成本高:agent 账号没有 actions rerun 权限(POST /actions/runs/{id}/rerun-failed 与 POST /check-runs/{id}/rerun 均 404),只能靠 owner 在 UI 点 Re-run Jobs,或推空提交整体重跑全套 CI。

背景与疑似根因

tests/lane-decisions-matrix.test.ts:72-78 的注释已记录这一类 Windows flake(#3490):listen(0) 偶尔落在 OS 保留/排除端口区间,server 发 error 而非 listening,导致测试 promise 永不 settle。aa562578a 做了两处加固:

  1. listenWithRetry(:79-91)— 包 upstream.listen(0),EACCES/EADDRINUSE 有界重试 ≤5 次;
  2. close()(:167-175)— closeAllConnections() 防 teardown 挂死。

疑似未覆盖路径:bili proxy 自身侧的 listen —— startServer({ port: 0, ... }) + await once(proxy, "listening")(:119-128)没有同样的重试包装。若 proxy 的 listen 命中同样的端口区间异常,once(proxy, "listening") 会 reject 或悬置,复现与本 issue 完全一致的签名。此为推测(Linux 本地无法复现 Windows 专属行为),需更多样本或代码路径确认后再修。

建议修法

  • 把 :119-128 的 proxy 侧 listen 纳入与 listenWithRetry 相同的有界重试逻辑(几行改动);
  • 或在 ci-tests harness 对该形状的错误('Promise resolution is still pending …' + cancelledByParent)加定向诊断:打印挂住的子测试名与其内部最后一个完成的 step,便于下次直接定位;
  • 修复后观察若干天 windows shard 复发率是否归零再关单。
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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions