Repository navigation
[PR] fix: log mid-stream abort origin — distinguish client hangup from bili-initiated abort (#7661) - #7670
[PR] fix: log mid-stream abort origin — distinguish client hangup from bili-initiated abort (#7661)#7670ranxianglei wants to merge 3 commits into
Conversation
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.12586-pr.7670.654a391This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr7670.tgz
npm install -g packageInstall instructions are refreshed on each push. |
d4ea03f to
38c7981
Compare
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) 查重: 不重复。 #7670 修的是「bili 主动 abort 被误标成 client-disconnect」(mid-stream abort 日志行);在途的 #5601 修的是相反方向——client-disconnect 被上游失败分类器误标成 Independent review of #7670(rebased head 核心机制成立,逐点核对过:
顺手修(commit 行为变更(有意,已写进 PR 描述):请求看门狗触发的 abort 现在记 标签:PR #7670 已带 8问(中文):
结论:机制成立、res 身份一致、无回归、CI 绿。我补上了请求看门狗这一处漏标的 abort 发起点(commit |
(ai: vllm-qwen/qwen3.8-27b) CI fix complete — What I did this run:
八问:
判定:CI 已全绿, |
(ai: vllm-qwen/qwen3.8-27b) Already green — no further work needed. This event reported Live re-verification on the current head Stopping here per the "already green" path. |
ranxianglei
left a comment
There was a problem hiding this comment.
Reviewed(reviewer: 本机 dog,非人类不合并,合并留给人)。结论:机制正确、CI 全绿、新测试本地 3/3 通过,可合并——合并前请先 rebase:master 已前进 29 个提交(其中 4 个动过 src/plugin.ts),文本无冲突但建议基于最新 master 再合。
验证过的点:
- Symbol.for 标签机制成立:logger 是叶子模块、所有 abort 位点本来就 import 它,跨模块读标签无循环依赖;
writable: true意味着重复写后写覆盖,我核对了各触发顺序(runaway guard → pipe finallyres.end()→ close handler 被!res.writableEnded守卫跳过;watchdog fire() → 先 end → 同样跳过),无误覆盖路径。 - 覆盖完整:
client aborted mid-stream全部 7 个输出位点(server.ts dispatch ×1、inline-engine ×3、plugin.ts chat/jsonl/responses ×3)都改走了abortMidStreamLine;relay.ts:1155 的client disconnected mid-stream按构造只在「客户端先断且 res 未 end」时触发(bili 主动断都会先res.end()被守卫挡掉),不需要也改不了。 - 最坏竞态无害:close 事件先于标签写入前 write() 已报错时,输出的是旧措辞
client aborted mid-stream——而那个场景恰恰是客户端先断,标签仍正确。
两个非阻塞备注:
upstream-watchdogorigin 定义了但暂无写入点(前向兼容没问题);将来若加上游看门狗 abort 路径,记得补setAbortOrigin。- 这个 PR 解决的是 #7661 里「谁先断的」从 bili 视角的判定(ask #1 的前半)。如果现场日志打出
client-disconnect(或无标签的旧措辞),即坐实 DSH 侧先断;但 DSH 侧被吞掉的那个真正传输错误(deepseek-harnessadapter.ts:80的 TRANSPORT 捕获把 cause 丢弃、消息里不可见)还得 DSH 仓库跟一个小改动才能看到全貌,建议另开 issue 跟踪。
9c56d4f to
0c50b98
Compare
(ai: vllm-qwen/qwen3.8-27b) Merge conflict resolved — PR is now mergeable (no conflict), and the rebased head is fully green (27 success / 19 skipped / 0 failures). What I did this run:
八问:
判定:冲突已解决( |
[ework] CI fix verified green ✓ |
1 similar comment
[ework] CI fix verified green ✓ |
…i-initiated abort (#7661) "client aborted mid-stream" fired for BOTH a client that hung up and a bili-initiated abort (runaway guard / upstream watchdog): both surface as a generic AbortError on a destroyed/ended response, so the log could not say who initiated it. #7661's ~20% DSH mid-stream aborts were stuck on exactly this observability gap. Tag each response with its abort origin (a global Symbol.for property, set at the initiation sites — the client close handler and the runaway guard) and render the line by origin in the catch sites. A bili-initiated abort now logs "bili-initiated abort mid-stream ... [origin: X]"; client-initiated and unknown-origin cases keep the exact old string (grep-stable). Behavior change (intended): bili-initiated mid-stream aborts log a distinct "bili-initiated abort mid-stream" line (was mislabeled "client"); client aborts are byte-identical to before.
The request watchdog (armRequestWatchdog) aborts the CLIENT's controller (requestAborts.get(res)), so its dispatch catch was mislabeled 'client aborted mid-stream' — the same observability gap #7661 closes for the runaway guard. Tag it 'bili-internal' (the previously-unused origin value) so the catch site renders 'bili-initiated abort mid-stream [origin: bili-internal]' instead. Pure log attribution; when/whether the watchdog fires is untouched.
…#7661) The unused-exports gate flagged AbortOrigin as INTERNAL_ONLY: the union type is referenced only within src/logger.ts (the three exported function signatures) and imported by no other module. Drop the leading export so the gate passes; the type still names the union at its definition site and no consumer imports it (the test uses string literals directly).
0c50b98 to
5395894
Compare
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Merge conflict resolved — PR #7670 is now mergeable (no conflict); rebased head pushed, static gates green. What I did this run:
Full test matrix is skipped — why, and what re-arms it: Local verification is green (typecheck + targeted abort-origin test + unused-exports on the combined tree) and the 11 fast static gates pass — so there is no red item. The authoritative full-regression verdict is pending a 八问:
判定:冲突已解决( |
[ework] CI fix verified green ✓ |
What this fixes
The
client aborted mid-streamlog line fired for BOTH a client that hung up AND a bili-initiated abort (runaway guard / upstream watchdog), because both surface as a genericAbortErroron a destroyed/ended response. The log could not say who initiated the abort — the exact observability gap #7661's ~20% DSH mid-stream aborts were stuck on (the user's report: "bili 侧没有记录中断原因,只有'客户端断开'").This PR adds abort-origin attribution so the log can distinguish the two.
What changed
src/logger.ts— newABORT_ORIGIN(a globalSymbol.forproperty) +setAbortOrigin/getAbortOrigin/abortMidStreamLine. The symbol rides the global registry so the tag is readable across module boundaries without an import cycle (logger is the one leaf every abort site already imports).src/server/relay.ts,src/server.ts— set the origin at the initiation sites: the client close handler (client-disconnect), the output-side runaway guard (runaway-guard), and the request-idle watchdog inarmRequestWatchdog(bili-internal— it aborts the client's own controller viarequestAborts, so its dispatch catch was the third site still mislabeledclient aborted mid-stream). This also puts the previously-unusedbili-internalorigin value to work.src/server.ts,src/inline-engine.ts,src/plugin.ts— the catch sites render the line by origin viaabortMidStreamLine.A bili-initiated abort now logs
bili-initiated abort mid-stream ... [origin: runaway-guard]instead of the mislabeledclient aborted mid-stream.Behavior change (intended)
client aborted mid-stream.bili-initiated abort mid-stream ... [origin: X](runaway-guard/bili-internal); client-initiated and unknown-origin cases keep the exact old string (grep-stable).Only the log attribution changes — when/whether an abort happens is untouched.
Test
tests/issue7661-abort-origin.test.tspins theabortMidStreamLineattribution (all 4 origins + unknown), thesetAbortOrigin/getAbortOriginround-trip on a realServerResponse, and the global-symbol identity.Not covered (follow-up, noted in #7661)
The upstream watchdog (
fetch-util.tsfetchWithTimeout) aborts its own controller, not the client's, and needsresplumbed in to tag the origin — a bigger change. It is already diagnosable via its ownupstream watchdog fired (phase, budget)line, and its 12–24 min budget makes it a non-trigger for #7661's 1–5 s aborts.Refs #7661