Skip to content

Commit 97defd6

Browse files
fix(ci): a stalled history fetch is killed and retried, not left to the step's wall (#34582)
<!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9R6fQuMSzSrRW2oowG4K2kQ)_ Fixes #34561 Governed: `.github/workflows/ci.yml`, `.github/workflows/lint.yml` (Tier H). **改根 ci.yml,需维护者同意。** Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:CI 里「Fetch this commit's history and the base branch」这一步(`test-plan`、`test`、`type-check-ui`、`test-ui-plan`、`test-ui` 五个 job 各一份)合成一个脚本 `scripts/ci/fetch-history.sh`。每次 `git fetch` 都带进度输出、单独一个进程组;一次尝试 60 秒没有任何输出,就连同 `git-remote-https` 一起杀掉,进入下一次重试。还在动的拉取(哪怕很慢)不会被打断。 - 为什么改:2026-11-16/17 五小时内四次步骤超时(push `6a7403ba` Test Core 7/8,队列 pr-34447 Test Core 5/8、pr-34381 Test UI 4/16、pr-34511 Plan Test Core shards)。能找到的三份日志一样:第 1 次 fetch 一直没输出,直到 8/14/20 分钟的步骤预算把它杀掉,原来的三次重试一次都没轮上;同一 run 的兄弟分片拉同样的历史只用 47–96 秒。所以不是深度或体量,是传输卡死而没人发现。 - 风险与回滚:没有调大任何超时,五个步骤的预算不变;拉取的内容(HEAD 全部祖先 + main,PR 进别的分支时再加那个分支,不拉 tag)不变。回滚即 revert 本 PR。 - 先看:`scripts/ci/fetch-history.sh` 的 `fetch_once`(看门狗 + 进程组杀);`ci.yml` 五处步骤现在都只剩 `run: bash scripts/ci/fetch-history.sh`。 - 两分钟验证:`pnpm check:fetch-history`,预期 46 项 PASS(约 40 秒,离线)。 - 需要你做的:**同意改根 ci.yml**,并按 Tier H 审批。 ## What changes - **`scripts/ci/fetch-history.sh`** (new): the step's body, once. Same refspecs, same `--unshallow` of HEAD's sha, same three attempts and 15 s / 30 s sleeps, same `::error::` and `History:` lines. New: `git fetch --progress` into a log, started under `setsid` so git and its `git-remote-https` helper share a process group of their own; a watchdog ends an attempt after 60 s in which the log did not grow (`kill -TERM` then `-KILL` to the group), prints the attempt's last progress line per phase (so the next stall names where it stopped), warns, and lets the loop retry. The 60 s is silence, not elapsed time: a healthy fetch writes at least once a second (enumerating, counting, compressing, then receiving with its byte rate). - **`.github/workflows/ci.yml`**: the five inline copies become `run: bash scripts/ci/fetch-history.sh`; budgets (8 / 20 / 20 / 14 / 14) untouched. The `test` job's comment, which sizes the budgets, now says why the body is shared and bounded; the three "verbatim but for its budget" notes say "the same script with its own budget". - **`ui/scripts/__tests__/select-affected-tests.test.ts`**: the two #22034 pins read the script for the fetch spelling and ci.yml for the call. - **`scripts/ci/fetch-history.selftest.sh`** (new) + `check:fetch-history` + a `History fetch self-test` step in lint.yml's `lint-ci-engine` job, next to the Test Core package-selection self-test. ## Evidence <details><summary>The three failed logs (attempt 1 silent until the budget; orphan helper reaped)</summary> ``` job 133708987651 merge group pr-34511 Plan Test Core shards 00:04:02 Run refspecs=… (attempt 1: git fetch --no-tags --unshallow origin ea1edf9… +refs/heads/main:…) 00:12:15 ##[error]The action 'Fetch this commit's history and the base branch' has timed out after 8 minutes. Terminate orphan process: pid (2206) (git-remote-https) job 133645669009 merge group pr-34381 Test UI (4/16) 22:02:27 → 22:16:40 timed out after 14 minutes; orphan git, git, git-remote-https job 133557664420 push 6a7403b Test Core (7/8) 19:35:18 → 19:55:31 timed out (20 min); orphan git, git, git-remote-https Sibling shards' successful fetch step, same runs (s): 47 48 48 49 53 61 63 63 96 (push) · 49 50 50 51 53 53 57 57 60 61 62 65 66 67 67 67 96 (pr-34381) ``` The pr-34447 run is past the run listings I read; the card's table reports the same signature. </details> <details><summary>Rehearsal against a real smart-HTTP server that stalls (git http-backend behind a node proxy; 400-commit, 6.8 MiB upstream; depth-1 clone first, like the checkout)</summary> ``` old step body, pack stalls after 2,000,000 bytes, step budget 120 s: exit 124 after 120 s, still shallow (1 commit) — the production signature new script, same stall, production bound (60 s): Attempt 1 … Receiving objects: 50% (574/1148) ::warning::git fetch wrote nothing for 60s after 12356 byte(s) of output, so it was killed with its process group (#34561). Attempt 2 … Receiving objects: 100% (1148/1148), 6.84 MiB | 30.60 MiB/s, done. exit 0 after 80 s, unshallowed (400 commits), no orphan helper new script, server never answers the pack request (5 s bound): killed after 0 bytes, attempt 2 green new script, slow but moving (146 KiB/s, 49 s, 5 s bound): one attempt, never cut ``` </details> ## Tests `bash scripts/ci/fetch-history.selftest.sh` — a stub `git` plays `fetch` per attempt and hands everything else (and every healthy fetch) to the real git against a throwaway file:// upstream: healthy (args, unshallow, no tags, History line), PR into another branch / into main, full clone (no `--unshallow`), silent hang then ok, hang after progress then ok (prints the stalled phase), slow-but-moving (never cut), three fast failures (red, named), three hangs (red inside three bounds, not at the wall); every hang checks the stub's child process is gone (the group kill). The last section pins the five ci.yml call sites and that no inline loop is left. 46 checks. <details><summary>Ablations (script mutated on disk, restored after)</summary> ``` A1 kill the pid, not the group × hang-then-ok / progress-then-hang / hang3 left no child process 3 FAILED A2 no stall bound (the old loop) × hang-then-ok names the stall · hang3 warns three times · hang3 is bounded 3 FAILED ``` </details> ## Verification - `node scripts/pm/dispatch-gates.mjs --ran` on f2767e1: 76 derived, 76 run, 0 NOT-MEASURED, every one exit 0. 63 of them ran on c216805, whose tree differs from f2767e1 only by the ui pin test; the 13 the second commit added ran on f2767e1. - f2767e1 updates the two pins in `ui/scripts/__tests__/select-affected-tests.test.ts` that read the inline loop (Test UI 1/16 went red on c216805 for exactly that): they now read the step's env and run line in ci.yml and the fetch spelling in the script. That file: 71 passed. - CI runs the rest; its result is read at the final head. --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01ADHkmSYe73LCZ6WxGFvcko <!-- signed: repo:objectstack#2 · os-steve · session_01ADHkmSYe73LCZ6WxGFvcko --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent f4a2d14 commit 97defd6

6 files changed

Lines changed: 361 additions & 99 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 24 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -800,29 +800,13 @@ jobs:
800800
- name: Checkout repository
801801
uses: actions/checkout@v7
802802

803-
# The `test` job's step of the same name, verbatim but for its budget
804-
# (its comment says why and sizes the budget).
803+
# The `test` job's step of the same name, the same script with its own
804+
# budget (the `test` job's comment says why and sizes the budget).
805805
- name: Fetch this commit's history and the base branch
806806
timeout-minutes: 8
807807
env:
808808
PR_BASE_REF: ${{ github.event.pull_request.base.ref }}
809-
run: |
810-
refspecs=('+refs/heads/main:refs/remotes/origin/main')
811-
if [ -n "$PR_BASE_REF" ] && [ "$PR_BASE_REF" != main ]; then
812-
refspecs+=("+refs/heads/$PR_BASE_REF:refs/remotes/origin/$PR_BASE_REF")
813-
fi
814-
head=$(git rev-parse HEAD)
815-
for attempt in 1 2 3; do
816-
deepen=()
817-
if [ "$(git rev-parse --is-shallow-repository)" = true ]; then deepen=(--unshallow); fi
818-
if git fetch --no-tags "${deepen[@]}" origin "$head" "${refspecs[@]}"; then break; fi
819-
if [ "$attempt" = 3 ]; then
820-
echo "::error::Could not fetch $head's history and ${refspecs[*]} after 3 attempts. This job's history readers need it, so this job stops here rather than reading from a shallow clone."
821-
exit 1
822-
fi
823-
sleep $((attempt * 15))
824-
done
825-
echo "History: $(git rev-list --count HEAD) commit(s) behind HEAD, shallow=$(git rev-parse --is-shallow-repository), no tags, refs: $(git for-each-ref --format='%(refname)' refs/remotes | tr '\n' ' ')"
809+
run: bash scripts/ci/fetch-history.sh
826810

827811
# Restore only: the `test` shards save this key.
828812
- name: Setup workspace
@@ -1097,7 +1081,16 @@ jobs:
10971081
# then a red step: a selection read from a shallow clone is the silent
10981082
# all-packages answer above, never a fallback this job may take quietly.
10991083
#
1100-
# FETCH BUDGET: the one line that differs between the four copies. Each
1084+
# ONE BODY, scripts/ci/fetch-history.sh, for the five jobs that fetch
1085+
# (`test-plan`, `test`, `type-check-ui`, `test-ui-plan`, `test-ui`).
1086+
# Each attempt that writes nothing for 60 s is killed with its process
1087+
# group and retried (#34561): on 2026-11-16/17 a stalled transfer held
1088+
# attempt 1 silent until this budget killed it, four times, so the retry
1089+
# never ran, while sibling shards fetched the same history in 47-96 s.
1090+
# A fetch that keeps moving is never cut. The script's header has the
1091+
# reading; its self-test runs in lint.yml.
1092+
#
1093+
# FETCH BUDGET: the one line that differs between the five steps. Each
11011094
# job gives the fetch what its wall leaves after its measured checkout
11021095
# and body (the max over 2026-11-08's runs on `main` and the queue),
11031096
# capped at 20 minutes: `test-plan` 8 (wall 10, body 0:37),
@@ -1116,28 +1109,13 @@ jobs:
11161109
# fits beside the body inside the 30-minute wall, so its budget only
11171110
# ends the red sooner and names the step. A red `test-plan` falls
11181111
# back to all eight shards, and each fetches for itself.
1119-
# A fetch that hangs ends red here, named, instead of eating the wall.
1112+
# A fetch that stalls is retried after 60 s of silence; one that keeps
1113+
# stalling ends red here, named, instead of eating the wall.
11201114
- name: Fetch this commit's history and the base branch
11211115
timeout-minutes: 20
11221116
env:
11231117
PR_BASE_REF: ${{ github.event.pull_request.base.ref }}
1124-
run: |
1125-
refspecs=('+refs/heads/main:refs/remotes/origin/main')
1126-
if [ -n "$PR_BASE_REF" ] && [ "$PR_BASE_REF" != main ]; then
1127-
refspecs+=("+refs/heads/$PR_BASE_REF:refs/remotes/origin/$PR_BASE_REF")
1128-
fi
1129-
head=$(git rev-parse HEAD)
1130-
for attempt in 1 2 3; do
1131-
deepen=()
1132-
if [ "$(git rev-parse --is-shallow-repository)" = true ]; then deepen=(--unshallow); fi
1133-
if git fetch --no-tags "${deepen[@]}" origin "$head" "${refspecs[@]}"; then break; fi
1134-
if [ "$attempt" = 3 ]; then
1135-
echo "::error::Could not fetch $head's history and ${refspecs[*]} after 3 attempts. This job's history readers need it, so this job stops here rather than reading from a shallow clone."
1136-
exit 1
1137-
fi
1138-
sleep $((attempt * 15))
1139-
done
1140-
echo "History: $(git rev-list --count HEAD) commit(s) behind HEAD, shallow=$(git rev-parse --is-shallow-repository), no tags, refs: $(git for-each-ref --format='%(refname)' refs/remotes | tr '\n' ' ')"
1118+
run: bash scripts/ci/fetch-history.sh
11411119

11421120
- name: Setup workspace
11431121
uses: ./.github/actions/setup-workspace
@@ -3865,8 +3843,9 @@ jobs:
38653843
- name: Checkout repository
38663844
uses: actions/checkout@v7
38673845

3868-
# The `test` job's step of the same name, verbatim but for its budget
3869-
# (its comment says why and sizes the budget). Here the readers are check:lockfile-integrity
3846+
# The `test` job's step of the same name, the same script with its own
3847+
# budget (the `test` job's comment says why and sizes the budget). Here
3848+
# the readers are check:lockfile-integrity
38703849
# (`git merge-base origin/<base> HEAD`), check:i18n-drift (the merge base
38713850
# with origin/<base> or origin/main), the affected type-check scope
38723851
# (`turbo --filter=...[BASE]`) and spec's build. On a shallow clone the
@@ -3876,23 +3855,7 @@ jobs:
38763855
timeout-minutes: 20
38773856
env:
38783857
PR_BASE_REF: ${{ github.event.pull_request.base.ref }}
3879-
run: |
3880-
refspecs=('+refs/heads/main:refs/remotes/origin/main')
3881-
if [ -n "$PR_BASE_REF" ] && [ "$PR_BASE_REF" != main ]; then
3882-
refspecs+=("+refs/heads/$PR_BASE_REF:refs/remotes/origin/$PR_BASE_REF")
3883-
fi
3884-
head=$(git rev-parse HEAD)
3885-
for attempt in 1 2 3; do
3886-
deepen=()
3887-
if [ "$(git rev-parse --is-shallow-repository)" = true ]; then deepen=(--unshallow); fi
3888-
if git fetch --no-tags "${deepen[@]}" origin "$head" "${refspecs[@]}"; then break; fi
3889-
if [ "$attempt" = 3 ]; then
3890-
echo "::error::Could not fetch $head's history and ${refspecs[*]} after 3 attempts. This job's history readers need it, so this job stops here rather than reading from a shallow clone."
3891-
exit 1
3892-
fi
3893-
sleep $((attempt * 15))
3894-
done
3895-
echo "History: $(git rev-list --count HEAD) commit(s) behind HEAD, shallow=$(git rev-parse --is-shallow-repository), no tags, refs: $(git for-each-ref --format='%(refname)' refs/remotes | tr '\n' ' ')"
3858+
run: bash scripts/ci/fetch-history.sh
38963859

38973860
- name: Setup Node.js
38983861
uses: actions/setup-node@v7
@@ -4175,23 +4138,7 @@ jobs:
41754138
timeout-minutes: 14
41764139
env:
41774140
PR_BASE_REF: ${{ github.event.pull_request.base.ref }}
4178-
run: |
4179-
refspecs=('+refs/heads/main:refs/remotes/origin/main')
4180-
if [ -n "$PR_BASE_REF" ] && [ "$PR_BASE_REF" != main ]; then
4181-
refspecs+=("+refs/heads/$PR_BASE_REF:refs/remotes/origin/$PR_BASE_REF")
4182-
fi
4183-
head=$(git rev-parse HEAD)
4184-
for attempt in 1 2 3; do
4185-
deepen=()
4186-
if [ "$(git rev-parse --is-shallow-repository)" = true ]; then deepen=(--unshallow); fi
4187-
if git fetch --no-tags "${deepen[@]}" origin "$head" "${refspecs[@]}"; then break; fi
4188-
if [ "$attempt" = 3 ]; then
4189-
echo "::error::Could not fetch $head's history and ${refspecs[*]} after 3 attempts. This job's history readers need it, so this job stops here rather than reading from a shallow clone."
4190-
exit 1
4191-
fi
4192-
sleep $((attempt * 15))
4193-
done
4194-
echo "History: $(git rev-list --count HEAD) commit(s) behind HEAD, shallow=$(git rev-parse --is-shallow-repository), no tags, refs: $(git for-each-ref --format='%(refname)' refs/remotes | tr '\n' ' ')"
4141+
run: bash scripts/ci/fetch-history.sh
41954142

41964143

41974144
- name: Setup Node.js
@@ -4364,8 +4311,8 @@ jobs:
43644311
- name: Checkout repository
43654312
uses: actions/checkout@v7
43664313

4367-
# The `test` job's step of the same name, verbatim but for its budget
4368-
# (its comment says why and sizes the budget).
4314+
# The `test` job's step of the same name, the same script with its own
4315+
# budget (the `test` job's comment says why and sizes the budget).
43694316
# Here the readers are the select step below (`git merge-base` against
43704317
# origin/<base ref>, then select-affected-tests.mjs's `git diff
43714318
# base...HEAD`) and spec's build. On a shallow clone the select step
@@ -4374,23 +4321,7 @@ jobs:
43744321
timeout-minutes: 14
43754322
env:
43764323
PR_BASE_REF: ${{ github.event.pull_request.base.ref }}
4377-
run: |
4378-
refspecs=('+refs/heads/main:refs/remotes/origin/main')
4379-
if [ -n "$PR_BASE_REF" ] && [ "$PR_BASE_REF" != main ]; then
4380-
refspecs+=("+refs/heads/$PR_BASE_REF:refs/remotes/origin/$PR_BASE_REF")
4381-
fi
4382-
head=$(git rev-parse HEAD)
4383-
for attempt in 1 2 3; do
4384-
deepen=()
4385-
if [ "$(git rev-parse --is-shallow-repository)" = true ]; then deepen=(--unshallow); fi
4386-
if git fetch --no-tags "${deepen[@]}" origin "$head" "${refspecs[@]}"; then break; fi
4387-
if [ "$attempt" = 3 ]; then
4388-
echo "::error::Could not fetch $head's history and ${refspecs[*]} after 3 attempts. This job's history readers need it, so this job stops here rather than reading from a shallow clone."
4389-
exit 1
4390-
fi
4391-
sleep $((attempt * 15))
4392-
done
4393-
echo "History: $(git rev-list --count HEAD) commit(s) behind HEAD, shallow=$(git rev-parse --is-shallow-repository), no tags, refs: $(git for-each-ref --format='%(refname)' refs/remotes | tr '\n' ' ')"
4324+
run: bash scripts/ci/fetch-history.sh
43944325

43954326

43964327
- name: Setup Node.js

‎.github/workflows/lint.yml‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3331,6 +3331,19 @@ jobs:
33313331
continue-on-error: true
33323332
run: pnpm check:select-shard-packages
33333333

3334+
# History fetch self-test (#34561). ci.yml's five "Fetch this commit's
3335+
# history and the base branch" steps run scripts/ci/fetch-history.sh, and
3336+
# its one property that a healthy run never exercises is the stall bound:
3337+
# an attempt that writes nothing is killed with its process group and
3338+
# retried, and one that keeps moving is not. A stub `git fetch` plays a
3339+
# silent hang, a hang after progress, a slow transfer and fast failures
3340+
# against a throwaway upstream, and the last section pins that all five
3341+
# ci.yml steps call the script. Offline; ~40 s.
3342+
- name: History fetch self-test
3343+
id: history-fetch-self-test
3344+
continue-on-error: true
3345+
run: pnpm check:fetch-history
3346+
33343347
# Rationale: `scripts/ci/scheduled-full-run.mjs` header (#16467).
33353348
- name: Scheduled full run self-test and concurrency gate
33363349
id: scheduled-full-run-self-test-and-concurrency

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@
165165
"check:pnpm-acquisition": "node scripts/check-pnpm-acquisition.mjs --self-test && node scripts/check-pnpm-acquisition.mjs",
166166
"check:workflow-status-functions": "node scripts/check-workflow-status-functions.mjs --self-test && node scripts/check-workflow-status-functions.mjs && node scripts/check-workflow-context-availability.mjs --self-test && node scripts/check-workflow-context-availability.mjs",
167167
"check:workflow-step-name-quoting": "node scripts/check-workflow-step-name-quoting.mjs --self-test && node scripts/check-workflow-step-name-quoting.mjs",
168+
"check:fetch-history": "bash scripts/ci/fetch-history.selftest.sh",
168169
"check:select-shard-packages": "bash scripts/ci/select-shard-packages.selftest.sh",
169170
"check:select-gate-families": "bash scripts/ci/select-gate-families.selftest.sh",
170171
"check:shard-attestation": "node scripts/ci-shard-matrix.mjs --self-test && node scripts/check-shard-attestation.mjs --self-test && node scripts/check-shard-attestation.mjs",

0 commit comments

Comments
 (0)