Repository navigation
Commit 4ab7129
ci(docs-deploy): retry a Vercel upload that dies on a connection failure, and name the cause when it keeps failing (#38826)
<!-- claude-projects-attribution: {"github_login":"huangyiirene"} -->
_Requested by **Irene** · [project
thread](https://claude.ai/code/project/chan_01TJXtQ1tVD26ecLDZxFS67x?thread=cmsg_01TJXtQ1tVD26ecLDZxFS67xYKeQBd9mhFCVMsawYWmMsa)_
Fixes #36022
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 用户无感:文档站部署上传失败时会自动重试,最多 3 次;读者只会看到文档站恢复更新。
- 为什么做:文档站已连续 3 次定时部署失败,从 11-30 06:59Z 起就没更新。日志显示每次都是某一个上传请求 300
秒没有回应,Vercel 命令行工具不重试这种错误,直接放弃整个部署。
-
出错会怎样:重试只针对还没创建出部署时的连接失败;一旦部署已创建、或遇到令牌失效等其他错误,都不重试、立即报错,避免重复发布。三次都失败时,报错写明每次用时和失败的那一行,原因仍待查。撤回本
PR 即还原。
- 要你做的:这是部署流程文件的改动,需要你批准后才能合并。合并后要不要手动跑一次 Docs Deploy,由座位决定。
## What I read
- The card, triage's comments 7288839768 and 7298197294, and seat 4's
reading 7065138531 (11-21).
- The deploy-step logs of the three failed runs (46421807466,
46487702664, 46551161614), the two green runs before them (46370316694
at 06:59Z, 46331835071 at 00:56Z), and the two 11-21 failures
(44846520026, 44877001751).
- The upload code in the published `vercel@60.1.3` bundle (`npm pack`,
`dist/chunks/chunk-U6AYMUHX.js`: `uploadFiles`, `isClientNetworkError`).
| Run | Head | Result | Upload began | Last progress line | `fetch
failed` | From upload start |
|:--|:--|:--|:--|:--|:--|:--|
| 46370316694 | 5a77a70 | green | 07:06:09.9 | 100% at 07:06:58.2 |
none | Ready at 07:07:17 (74 s step) |
| 46421807466 | 8426fa0 | failure | 12:52:41.4 | 100% at 12:53:45.8 |
12:57:43.6 | 302.2 s |
| 46487702664 | 8455490 | failure | 18:50:22.7 | 100% at 18:51:24.1 |
18:55:24.3 | 301.5 s |
| 46551161614 | d97aaae | failure | 01:16:53.9 | 50% at 01:17:20.9 |
01:21:56.0 | 302.1 s |
Findings:
- **Measured:** all three failures stop 301-302 s after the `Uploading
[---]` line, with one `fetch failed` (no HTTP status, no 429, no size or
quota message), then `AbortError` for the other uploads in flight
(46551161614 also shows 71 `Upload aborted` lines for the queued ones;
the other two show 2 `AbortError` and no `Upload aborted`). In two of
them every byte had been sent a minute earlier; the step then waited
about 4 minutes with no output. A green upload of the same size takes
about 50-60 s.
- **Inferred:** 300 s is the default response timeout of Node's fetch
(undici `headersTimeout` / `bodyTimeout`). So one request from the first
batch got no answer at all, and the timeout fired. The CLI prints `fetch
failed` without its cause, so the timeout type is not printed in the
log. This is not the CLI's own upload timeout: 60.1.3 sets none on file
uploads. It is not a reset either, since a reset would fail early.
- **Measured (CLI source):** `uploadFiles` retries a failed file (5
retries) only when the error text, or its cause, contains ETIMEDOUT,
ECONNRESET, ECONNREFUSED, ENOTFOUND, EAI_FAIL, `socket hang up` or
`network socket disconnected`. Any other error goes to "Other error,
bailing": it aborts every in-flight upload, which is where the
`AbortError` and `Upload aborted` lines come from, and the deploy exits
1. An undici timeout matches none of those texts. So one unanswered
request fails the whole deploy, even though the CLI has a retry loop.
- **The 11-21 failures are a different shape:** they stopped 56 s and 71
s in, which is a dropped connection, not the 300 s stall. The CLI did
not retry them either.
- **What changed between 5a77a70 (green) and 8426fa0 (first red):**
nothing on our side that the logs show. The workflow is the same, CLI
60.1.3 and Node 22.23.5 are the same, and the runner image is the same
(`ubuntu26/20261122.9`, which also deployed the green 00:56Z and 06:59Z
runs). The output grew by 48 deployment files and 2.4 MiB (9655 → 9703
files, 473.3 → 475.7 MiB distinct, from the measurement step). The
failures came from three different runner regions (northcentralus,
westus2, centralus). Why the request went unanswered is NOT MEASURED:
the network path, Vercel's upload endpoint, or one file that stalls
every time are all still open (three runs in a row stopped at the same
point, and a retry re-sends only what the API says it lacks, so a
per-file stall is not ruled out).
## What changes
`.github/workflows/docs-deploy.yml`, the `Deploy the prebuilt output to
production` step only. The measurement step is unchanged.
- **Bounded retry, 3 attempts, waiting 30 s and then 60 s.** Each
attempt is a new CLI process with new connections, and it asks the API
again which files are missing. The logs show single, isolated stalls
(green runs before and between, at different hours), so a fresh attempt
is the remedy they support. No log measures the right wait, so the waits
are kept short, enough for a new connection pool, so that the worst case
fits the job clock (see budget below).
- **Retries only when the attempt printed nothing on stdout** (CLI
60.1.3 prints only the deployment URL there, at `created`; any stdout
counts as a created deployment, L2 N5) AND either its fatal error line
(`Error:` / `TypeError:` at line start, not a warning earlier in stderr)
carries a connection-failure text (`fetch failed`, ECONNRESET,
ETIMEDOUT, `socket hang up`, `other side closed`) or the attempt hit its
own cap. The fatal lines are matched from a here-string, not a pipe:
under `pipefail`, `printf | grep -m1` reads false once the lines pass
the 64 KiB pipe buffer (L2 S2). `Upload aborted` and `AbortError` are
deliberately not on the list: they follow ANY bail, including an HTTP
4xx on one file.
- **Never retried once a deployment exists** (L2 S1). CLI 60.1.3 prints
the URL at `created`, before Building, Ready and Aliased, so an attempt
that printed a URL and then failed (a status poll's `fetch failed`, or
the cap while waiting for Ready) has a deployment Vercel goes on to
finish, and a retry would publish a second one. That run fails with an
`::error::` naming the URL and saying its final state is unknown, and
writes `url=` so the run summary shows it.
- **Also never retried:** a refused token, a config error, an HTTP error
with a message (the `::error::` quotes the CLI's first fatal line), and
an exit 0 that printed no URL (the `::error::` says whether a deployment
exists is unknown). No message claims production kept its previous
deployment unless that is known.
- **Each attempt is capped at 6 minutes** (`timeout --kill-after=30s
6m`, which signals the CLI's whole process group). A failed attempt took
307-312 s (jobs API step times) and a green one 74 s. The cap only stops
a hang somewhere other than the upload (undici already ends a stalled
upload at 300 s) from using up the job's 30 minutes. **No longer
timeout:** a request with no answer for 300 s, when the whole upload
takes 60 s, is stalled, not slow. Waiting longer would only delay the
failure.
- **Budget:** the deploy step started 5:12-6:29 into the failed runs.
Worst case, counting `--kill-after`, is 3 × 6.5 min + 90 s = 21 min,
about 27.5 min with the build, inside the job's unchanged
`timeout-minutes: 30`. The expected stall path is 3 × ~310 s + 90 s ≈ 17
min.
- **The failure says what it saw.** A deploy that needed a retry stays
green with a `::warning::` that lists each earlier attempt (its failing
line and seconds), so a recovered abort is still visible on the run
page. When all attempts fail, the `::error::` lists every attempt's
failing line and time, says no attempt got a deployment URL back (so the
run created no deployment the CLI knows of), and explains the two
shapes: ~300 s means an upload request that got no answer within Node
fetch's timeout, and a minute or so in means a dropped connection. It
does not name a cause. It points at the next reading if this repeats:
which file the stalled request carried (a `--debug` run logs `File <sha>
(<name>) uploaded` per file, and the stalled one never gets that line).
Exit 137 is `--kill-after`'s SIGKILL; an out-of-memory kill would also
read 137 and be labelled the cap (L2 N2, noted in the comment). stderr
is still streamed live (`tee`), so the log keeps the per-line timestamps
this reading was made from.
- **CLI stays pinned at 60.1.3.** The same version deployed the ten
green runs before the first failure, so the logs give no reason to move
it. Newer majors (66.x and later) also replace the JS CLI with a
native-binary launcher (`@vercel/vc-native-*` optionalDependencies), so
the upload code changes entirely and could not be read here. Moving the
pin is a separate reviewed change.
- `skip-changeset`: a workflow file, nothing publishes.
## Tests
- The step's `run:` block, extracted from the YAML and run under `bash
-e` (the runner's shell) with a fake `npx` on `PATH`, one scenario per
run:
- `ok`: 1 attempt, exit 0, `url=` written.
- `stall,ok` (`fetch failed` then success): 2 attempts, exit 0, `url=`
written, `::warning::` names attempt 1.
- `stall,stall,stall`: 3 attempts, exit 1, `::error::` lists all three.
- `auth` (a non-network `Error:`): 1 attempt, exit 1, no retry,
`::error::` quotes the CLI line.
- `nourl` (exit 0 with empty stdout): 1 attempt, exit 1, no retry.
- `hang,ok` with the cap at 2 s: attempt 1 killed by `timeout` (the
grandchild `sleep` went with it, and `tee` returned), attempt 2 deploys,
exit 0.
- `stall2` (run 46487702664's shape: `Error: This operation was
aborted`, then `TypeError: fetch failed`), then `ok`: retried, exit 0.
- `postcreate` (URL on stdout, then `Error: fetch failed`, exit 1): 1
attempt, exit 1, no retry, `::error::` names the URL, `url=` written.
- `posthang` (URL on stdout, then a hang) with the cap at 2 s: 1
attempt, exit 1 (124 inside), no retry, `::error::` names the URL and
the cap.
- `warnauth` (a `WARN! ... fetch failed` warning line, then a
non-network `Error:`): 1 attempt, exit 1, no retry.
- `bigfatal` (`Error: fetch failed`, then 2000 more `Error:` lines,
about 130 KB), then `ok`: retried, exit 0. The same case on 702a8ff
(the pipe) went red with "not a connection failure", so the case
reproduces S2.
- `prefixurl` (stdout `Deployed to https://…`, then `Error: fetch
failed`, exit 1): 1 attempt, no retry, `::error::` names the extracted
URL.
- `shellcheck -s bash` on the extracted block: clean.
- The YAML parses, and the step's `env` reads `DEPLOY_ATTEMPTS: '3'` and
`ATTEMPT_LIMIT: '6m'`.
- No check-run runs this step (Docs Deploy runs only from `main`). Its
first real run is the first deploy after merge. Per the card's thread I
have not run or dispatched Docs Deploy.
## Verification
Read first: the new comment block and step above `Publish the run to the
summary` in `.github/workflows/docs-deploy.yml`.
Two-minute check after merge: on the next Docs Deploy run (scheduled, or
"Run workflow" on `main` when the seat decides), the deploy step logs
`Deploy attempt 1 of 3` and ends at `Deployed:`. If it needed a retry, a
warning annotation says so. If every attempt fails, the error annotation
says which shape each attempt took.
<details><summary>Gates at 932a261</summary>
- `node scripts/pm/dispatch-gates.mjs --commands`: 36 derived families,
each run with its exit code captured before any pipe
(`NODE_OPTIONS=--max-old-space-size=8192`), all exit 0. `--ran`: 36
derived, 36 run, 0 NOT-MEASURED, 0 UNRUN.
- `node scripts/check-commit-card-trailers.mjs --range
origin/main..HEAD`: clean.
- `node scripts/pm/overlap-check.mjs`: VERDICT clean, merges cleanly
into origin/main (7625001).
- `dispatch-gates.mjs --tier .github/workflows/docs-deploy.yml`: no
path-derived mandate. The path is a governed surface (Tier H).
- The same 36 families were derived and green at 239bde1 and 702a8ff;
on those heads every CI check-run concluded success (30 each) or skipped
by path.
- Every family CI runs: this PR's check-runs.
</details>
---
_Generated by [Claude Code](https://claude.ai/code)_
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01J8VVAm7mxkbu9XywnqFzRc
<!-- signed: repo:objectstack@huangyiirene · huangyiirene ·
session_01J8VVAmaT5PwLmXgonaxjYG -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 1de73c0 commit 4ab7129
1 file changed
Lines changed: 129 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
222 | 222 | | |
223 | 223 | | |
224 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
225 | 285 | | |
226 | 286 | | |
227 | 287 | | |
228 | 288 | | |
| 289 | + | |
| 290 | + | |
229 | 291 | | |
230 | 292 | | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
237 | 360 | | |
238 | 361 | | |
239 | 362 | | |
| |||
0 commit comments