Repository navigation
[PR] fix: surface async log-file open failures; gate #2864 stderr mute on verified open - #3873
ranxianglei wants to merge 1 commit into
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.4642-pr.3873.35346b7This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr3873.tgz
npm install -g packageInstall instructions are refreshed on each push. |
d3041b4 to
fa9e64f
Compare
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复 —— 本 PR 即 #3857 的实现(Closes #3857);检索 open+closed 无并行修复同一缺陷的 PR。相邻的 #2864(mute 决策本身)、#1233(stderr EPIPE 风暴)是不同机制,本 PR 只消费其契约不复现其问题。分支内两个顺手小修(docs-sync 再生成、unused-exports 去导出)均为 master 既有红,已独立标注,机制与本 PR 无关、范围正确。 标签: bug / scope/other / p2(日志基础设施缺陷;可用性无损,特定触发——OS 拒绝日志路径——下诊断能力全毁;定级与 #3857 一致) 独立审核结论(基于对 head
|
…rades immediately (#3857) Conflict-resolution rebase onto master: master already carries the main #3857 fix via #3858 (delivered-write liveness + async-failure warn routing), so this branch now keeps only the residual delta of the parallel implementation: - openStream verifies the fd at 'open' (fstat S_IFDIR check): win32 (node 22 observed in CI) hands out an fd for a DIRECTORY whose writes then always fail — reject it at open so the degradation surfaces immediately (one-shot warn naming the cause, zero lost lines) instead of on the first lost line. Liveness still arms on the first DELIVERED write only (#3858 design kept); character devices (/dev/null logFile) stay legal. POSIX unchanged (open fails EISDIR before 'open' fires there). - tests/logger-async-open-failure.test.ts narrowed to the two regression pins the merged silent-loss suite does not carry: mid-life leg death stays one-shot across the per-line reopen loop; isFileLoggingActive() reports a pending stream as not live (feeds the #2864 mute decision).
2fe290f to
d88dc72
Compare
(ai: vllm-qwen/qwen3.8-27b) 冲突已解决:分支 rebase 到当前 master、冲突消解、已推送(新 head 查重:与已合并的 #3858 同机制家族(同一 #3857 缺陷)——主修复部分重复(已在 master),本 PR 保留的是它没有的增量(见下),故不关闭。 冲突的真正性质不是普通文本碰撞,而是设计级碰撞:本 PR 在途期间,master 合入了 #3858——同一个 #3857「日志静默丢失」缺陷的另一套并行实现,两者都改了
处置:以已合并的 #3858 设计为基准(它的存活判据更严——不存在"先 mute stderr、随后写失败"的空窗),从本 PR 只保留 master 真正缺失的增量,压成一个干净 commit:
原 4 个 commit 里的竞争实现主体、重复测试、文档漂移全部作为重复丢弃(已经由 #3858 在 master 上)。PR 标题/正文仍是原完整修复的描述;当前实际 diff 只有 2 个文件(+120/−4)。 八问:
行为变更披露(有意):logPath 指向目录时,Windows 上的降级 warn 从"丢第一行后、报原始写错误码"变为 open 时立即触发、消息含 验证:本地定向跑三个 logger 套件 8/8 绿(含 #3858 已合并套件全部 4 例)、typecheck + build 绿;全量回归以远程 CI 对新 head 的结果为准。 判定:冲突已解、PR 可合(待 CI 绿 + 人工合并)。若你认为这个增量不值得单独走一轮合并,也可以直接关掉本 PR——主修复无论如何都已在 master;我的建议是合入(小、有测试、给 #3857 收尾闭环)。 |
|
(ai: zhipuai-lb/glm-5.3) 目标 issue #3857 已关。列车审查时确认:内容已落地/不再需要,关单处理。 |
Closes #3857
What & why
When the OS refuses the log file (EISDIR/EACCES/EPERM — Windows integrity/sandbox/AV locks, permission denials elsewhere), the async open failure reaches only the stream's
errorevent, which destroyed the stream in silence. The one-shot degradation warn (warnReopenFailed) was reachable only fromgetStream()'s try/catch — sync throws (e.g.mkdirSyncfailures) alone. Result: every log line dropped with zero warning; only in-memory diagnostic state showed anything.Worse in launcher-spawned children (
BILI_LAUNCH_TOKEN, stderr already redirected to the %TEMP% port log): the #2864 mute decision readisFileLoggingActive()right afterconfigureLogger(), and that check counted a pendingcreateWriteStreamas live (writable but not yet open). So stderr got muted before the async open resolved; when the open was then refused, both sinks were dead at once — and the un-mute insidewarnReopenFailedcould never run because the warn itself never fired.Fix
errorhandler routes intowarnReopenFailed(err)— one-shot warn + un-mute of the stderr fallback, covering async open/write refusals.isFileLoggingActive()requires the verified fd (streamFd !== undefined), not just a writable pending stream.onFileLegLive(fn)hook fires once per verified open (immediately if already live); server.ts registers the [noise] 观测噪音三件:启动横幅同秒重复 24 次 / reasoning-pair-violated 每请求重报(单会话 276 条) / %TEMP% 端口日志无轮转(5 天 31.7MB) #2864 mute on it instead of probing stream state at configure time. A refused open never fires it → stderr stays live.reopenWarnedreset moved from stream creation to the verifiedopenevent: the pending→fail→retry loop otherwise re-arms the one-shot per doomed stream (a warn-per-line storm — the exact anti-pattern logger EPIPE feedback loop: async stream error re-enters uncaughtException handler — 77MB spam, rotation destroys forensic logs #1233 guards against).Behavior changes (old → new)
configureLogger()on pending-stream writability (effectively always muted, even when the open later refused); new = fires from the stream'sopenevent (fd verified). Consequence: a few extra duplicate startup lines may land in the port log between configure and open completion (ms-scale, bounded); on a refused open the mute no longer happens at all — that is the fix.isFileLoggingActive()semantics: pending-inclusive → verified-open-only. Its sole production caller was server.ts (now uses the hook); tests updated accordingly.onFileLegLive()— additive; no behavior change for existing callers.reopenWarnedreset timing: on stream creation → on verified open. Sync-failure path unchanged (the reset never ran on throw before either); async path goes from 0 or N warns to exactly 1 per degradation episode.Config surface: none (no new env vars / config keys / flags). No kernel/ or pi-subagents/ changes.
Tests
tests/logger-async-open-failure.test.ts(6 tests): deterministic cross-platform async open failure (directory at the log path → EISDIR): muted child gets exactly one warn + stderr fallback alive + lines survive; one-shot holds across the retry loop (a healthy open arms the counter first, then rename+mkdir breaks the path under 5 interleaved writes — 5 doomed streams, 1 warn); hook contract (fires once per successful open / immediately when registered while live / never on refusal);isFileLoggingActivefalse on the pending stream, true after open. Red before the fix (silent loss reproduced), green after.tests/logger-stderr-mute.test.ts: the "file leg live" assertion no longer races a pending stream — it waits for the verified open via the hook (the old assertion encoded the All logs silently lost when the log file fails to open: no warning on async open failure, stderr fallback permanently si | 日志文件打不开时全部日志静默丢失:异步打开失败不告警、stderr 兜底被永久静音 #3857 defect).Rebased onto current master (
fa9e64f91) — two extra independently-labeled commits for PRE-EXISTING master gate reds that blocked this PR's (and every PR's) test lanes vianeeds; both verified red on clean master before touching them:docs:regenerated CONFIGURATION.md / CONFIGURATION.zh-CN.md from the website seeds — drops 2 stale duplicatestorage.*rows per file (a pre-Storage wrap-up: 6 fixes + switch default mode to full (single PR) | 存储收尾六修 + 缺省模式翻 full(一个 PR 统一处理) #3818 row claiming the shadow default, a pre-SQLite unified storage degraded to legacy-only (bili v0.1.201, node v20.19.5, win32-x64) #3788 auto-download row missing the cooldown text) that were committed without regeneration; clears thedocs-syncgate.fix(log-mask):unexportedmaskUrlForPublish([security][web] Diagnostics blob prints private relay hosts verbatim in the config section — the "secrets masked" header only masks values, not hosts | 诊断包 config 段原样输出内网中转地址:标题说"密钥已遮蔽",但只遮值不遮主机 #3811 follow-up) — later refactors moved every external call site tomaskUrlsForPublish, leaving the single-URL form module-internal; dropped per the gate's INTERNAL_ONLY prescription, zero runtime effect (the bundler inlines either way); clears theunused-exportsgate.Neither commit touches All logs silently lost when the log file fails to open: no warning on async open failure, stderr fallback permanently si | 日志文件打不开时全部日志静默丢失:异步打开失败不告警、stderr 兜底被永久静音 #3857 behavior.