Repository navigation
[PR] fix(fetch): preserve transport error when a non-ok response body fails to read (#6133) - #6159
ranxianglei wants to merge 1 commit into
Conversation
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.9362-pr.6159.2f2d9e1This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr6159.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重: 缺陷本身不重复,但存在同根因的并行 PR——#6134(报告人 Afloat16,Nov 10 15:21)与 #6159(owner,Nov 10 23:40)两个 open PR 都修 #6133 的同一根因。按「一个 thread 一个 fix PR」应二选一合并、关掉另一个(我不关单,等你拍板)。本审核针对 PR #6159。 标签(建议,未落库): Review — PR #6159: preserve transport error when a non-ok response body fails to read (#6133)Verdict: correct & minimal fix — mergeable once (a) head has a clean green CI pass and (b) you pick #6159 vs #6134. Two non-blocking nits below. What I verified (independent read of the diff + surrounding code):
Behavior change (old→new), disclosed: body-read-failure on a non-ok response: swallow-to- 结构化八问(中文)
收工判定: 代码正确、最小、回归面已清点——可合,前提是 (a) head 拿到一次干净 CI 绿(当前 test 矩阵为 cancelled/pending),(b) owner 在 #6134 / #6159 二选一合并并关掉另一个(我不关单)。两处小项(PR 正文调用点数 2→实为 3;测试缺正向「完整 body 仍重试」行)建议顺手补进 #6159,均非拦点。 |
[bot] 🏷 Bottom line (full review is the floor above — not re-posting it): PR #6159's fix is correct & minimal and restores Mergeable once two things clear:
Non-blocking nits: PR body says "both call sites" but there are three ( |
…s to read (#6133) fetchWithRetry swallowed any post-headers body-read rejection via response.text().catch(() => "upstream error"), then replayed on the bare HTTP status. A body that never completed (transport body-timeout, abort, mid-stream reset) made the status an unreliable verdict; the retry loop stacked the full idle budget across attempts while hiding the real cause from callers. Guard the read instead: on body-read failure clear the watchdog and rethrow the original transport error unchanged — no replay. A fully-received error body still follows the normal HTTP-retry path below. Restores the function's own documented contract ("headers/body timeouts and aborts still propagate unchanged — NOT retried"). No kernel or configuration changes. Fixes #6133
1d7725e to
d4fb820
Compare
Conflict resolved · this PR is a duplicate of #6134 · the red test is flaky (re-triggered). 1. Conflict — resolved. The PR conflicted with master. I rebased it onto the current master ( 2. Duplicate — needs your call (labeled
3. Red CI test — flaky, not caused by this PR (re-triggered). The failing check 八问(结构化结论):
待你拍板:本 PR 是 #6134 的重复(修复已在 master),已打 |
CI is now green. The re-triggered The conflict resolution and duplicate finding from my previous comment stand: this PR is a duplicate of #6134 (fix already on master via #6439 / |
Summary
Fixes #6133.
fetchWithRetryswallowed any post-headers body-read rejection viaresponse.text().catch(() => "upstream error"), then replayed on the bare HTTP status. Once headers had arrived, a body that failed to read (transport body-timeoutUND_ERR_BODY_TIMEOUT, abort, mid-stream reset) meant the response never completed — its status was not a reliable verdict, and the body text needed for transient classification was absent. The retry loop replayed such responses on transient statuses, consuming the full idle-timeout budget on every attempt while hiding the real transport cause from callers.Fix
Guard the read instead of swallowing it: on body-read failure, clear the watchdog and rethrow the original transport error unchanged — no replay. A fully-received error body still follows the normal HTTP-retry path below (unchanged). Pre-response retry behavior (#1351/#1454/#1693) is untouched.
This restores
fetchWithRetry's own documented contract: "headers/body timeouts and aborts still propagate unchanged — NOT retried."Behavior change (old → new)
"upstream error", replayed up to N times on transient statuses (stacks the full idle budget per attempt), terminalUpstreamHttpError(status, "upstream error")UND_ERR_BODY_TIMEOUT/AbortError/ …) propagated unchanged; no replayisTransientUpstreamErrorWHY: the status is unreliable when the body never completed, and the body text needed for the transient check is absent; replaying consumed the full idle-timeout budget on every attempt while hiding the real cause. A complete error body still retries normally.
Callers verified safe
Both
fetchWithRetrycall sites already receive raw transport errors today (from the pre-response path); this change makes post-headers body-failure consistent with pre-response failure — no new crash or dropped-handling path:src/loop/core.tsthrottledSendcatch — skips the 429-governor note (correct; it is not a 429) and rethrows.src/compress-loop-responses.ts.catch— logs onlyUpstreamHttpError, rethrows otherwise.Config surface
None. No new env/config/CLI fields; no kernel changes.
Verification
tests/upstream-fail.test.ts("…NOT replayed — the transport cause is preserved ([Bug] HTTP error-body timeouts are swallowed and replayed as transient HTTP failures #6133)") covers 503+body-timeout, 500+abort, 400+body-timeout; asserts the error propagates unchanged (object identity), the transport is invoked once (no replay), and no retry callback fires. Confirmed FAILS on unchanged source.npm run typecheckclean;npm run buildclean.