Repository navigation
[PR] fix(logger): log file open failure now warns + falls back to stderr instead of total silent loss - #3858
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.4582-pr.3858.1ba8e94This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr3858.tgz
npm install -g packageInstall instructions are refreshed on each push. |
9abb7f3 to
cfd2f7c
Compare
|
(ai: vllm-qwen/qwen3.8-27b) Rebased onto current master (48d45e7) — the branch was ~30 merges behind, including the #3818/#3819 storage-mode flip and #3790 bootstrap diagnostics. Rebase was conflict-free; logger suites green locally (logger-silent-loss + logger-stderr-mute + log-mask, 25/25) and typecheck clean on the new base. Two labeled drive-by commits added on top (no behavior change), because master itself is currently red on two gates this PR's CI also runs — reproduced locally on pure master, so this is inherited redness, not from this diff:
No new issue filed for these (few-line fixes riding an in-flight PR); flagging so the same two commits can ride whichever in-flight PR lands first. |
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复。 检索 open+closed issue 与近期 PR(按失败签名:logger 静默丢失 / 异步 open 失败 / stderr mute 竞态),无既有覆盖;相邻工作 #2864(launcher 子进程静音 stderr)、#1233(EPIPE 风暴降级)、#1718(日志脱敏)机制均不同——#3857 线程已做过同样比对,复核一致。本 PR 是 #3857 的修复 PR,一 issue 一 PR,无并列重复修复。 标签: pr / bug / scope/other / p2 —— 缺陷类;logger 属宿主基础设施(kernel/wiring/storage/ui/ci/docs 均不属);与 #3857 定级一致(触发时整条日志腿静默全灭、可用性不受损 → p2);不打客户端标签(跨所有 launcher 车道)。 开始审核:拉取 |
…lent loss (#3857) Two fail-open holes in the tee logger's degradation path: 1. createWriteStream opens asynchronously; a failed first open surfaced as an 'error' event that only destroyed the stream — no warn was ever emitted and the one-shot reopen-failure warning stayed unreachable for the most common failure class (the log directory not being creatable at startup). 2. isFileLoggingActive() returned true for a PENDING stream whose fd had not opened yet. The launcher child mute (#2864) consulted it right after configureLogger(), so it muted stderr before the open result was known; on open failure both sinks were dead and every subsequent line — including the storage degradation warnings — vanished with no trace in any file. Fix: route stream 'error' events through the existing one-shot warning (stderr-only fallback + unmute), and move the mute decision behind a new onFileLegLive() hook that fires once per PROVEN open (fd captured). The reopenWarned reset moves from stream creation to the proven-open point so one degradation episode warns exactly once. isFileLoggingActive() now requires a captured fd. Behavior change (disclosed): launched children (BILI_LAUNCH_TOKEN set) now mute stderr only after the log file has actually opened; if the first open fails, the child logs one [warn] to stderr and continues stderr-only instead of going silent. Manual starts are byte-identical. Tests: new tests/logger-silent-loss.test.ts (dir-as-log-path = deterministic cross-platform async open failure; worst-case pre-mute; one warn per episode; late lines reach restored stderr; hook exactly-once / never-on-failure / immediate-on-late-registration); tests/logger-stderr-mute.test.ts test 1 now waits for a proven open before asserting activity (the old assertion encoded the racy pending-stream semantics).
…ows (master-red docs-sync gate) Drive-by fix, labeled: master 48d45e7 fails docs-sync because the committed CONFIGURATION.md / .zh-CN.md still carry two superseded table rows each (the old storage.unified 'unset (shadow)' row and an old storage.sqliteAutoDownload row without the #3788 cooldown text). tools/gen-config-docs.mjs generate deletes exactly those 4 rows; no other content changes.
…en event (#3857) The windows-latest node-22 CI shard reproduced the #3857 field shape (win32 hands out a valid fd for paths whose writes then always fail — e.g. a DIRECTORY): the shipped version keyed the degradation-episode reset and the onFileLegLive hook on the 'open' event, so every retry cycle re-armed the one-shot warn (warn storm) and the hook fired over a never-delivering leg — which would have muted stderr (#2864) over a dead file leg. Liveness is now proven by the first DELIVERED write: - 'open' only records the fd (orphan-inode detection); it no longer resets reopenWarned or fires the hook; - noteProvenWrite() ends the degradation episode and fires the hook once; - isFileLoggingActive() / onFileLegLive() immediate-fire require the proven state; error/rotation/close paths reset it. Behavior change (disclosed): launcher-spawned children engage the stderr mute after the first byte actually lands in bili.log instead of after the first open completes — strictly safer (never mutes over a non-deliverable leg); manual starts are unaffected. If no line ever reaches the file, stderr stays unmuted (duplicate temp-log noise in a degenerate zero-line case, never silent loss). Tests: the dir-as-log-path fixture now pins the contract on DELIVERY on every platform (POSIX fails the open EISDIR; win32/node-22 opens fine and only writes fail); mute-suite test 1 seeds a write before asserting liveness. Local: 17/17 logger suites green, typecheck clean.
…iveness waits The three #3857/#2864 tests waited on isFileLoggingActive() (fd established on the 'open' event) before asserting delivery-based state (hook fired / leg live). 'open' precedes the first flushed write, so the fd can be visible while no byte has been delivered yet - measured 22% miss rate at tight polling. The 20ms test polling masked the window locally but it is not deterministic under load. Wait on actual delivery instead: hook fire count (hook registered pre-seed) or a byte on disk (existsSync-guarded stat), which is monotonic and race-free.
400afa6 to
e5ed953
Compare
(ai: vllm-qwen/qwen3.8-27b) 审核完成(查重结论见首条回复:不重复)。本轮为完整审核结论。 独立审核动作(未照抄 PR 描述):
发现的问题(已修):三个 #3857/#2864 测试用 bundled commits 独立核查:① 八问:
小注:PR 描述写 launcher 套件 332/332,我实测 403/403(master 上新测试增多导致计数漂移,无害)。 判定:可合。按 §7.4,本 PR 含 fallback 行为变更(静音时机属产品决策)且触碰 src/server.ts 热文件,不走自动合并,请人工合并:#3858 |
(ai: vllm-qwen/qwen3.8-27b) 这条说明早于我上一轮审核到达,先同步现状,再报对你两个论断的独立复核结果。 现状更新(详情见我上一条八问回复):分支已从你描述的 48d45e7 基础进一步 rebase 到当前 master(39fb841,含你提到的 #3818/#3819/#3790 及之后的变更),并追加了一个测试确定性修复 commit 对「master 本身在这两个门禁上红」的独立复核(在纯 master 39fb841 的干净 worktree 里复现,不是只信描述):
另外核对过:这两个修复尚未被其他 PR 带进 master(master 今天仍是红的),所以「谁先落地谁带上」目前仍由本 PR 承担。按几行级小修调度纪律,不另开 issue,同意你的处置。 八问(仅针对本轮新增内容——两个 drive-by commit 的正当性与当前分支状态):
判定维持上一条:可合,人工合并(fallback 行为变更 + src/server.ts 热文件,§7.4 不走自动合并)。#3858 |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) windows-latest node-22 分片失败已修复,现全绿。 失败根因(不是测试问题,是实现缺陷):node-22 win32 上 修复(commit 400afa6):存活判据改为第一个字节真正落盘—— 验证:本地 logger 六套件 17/17 + typecheck 干净;目录 fixture 现在在两个平台上分别走 POSIX(open 失败 EISDIR)/win32(open 成功写失败)两种形状钉住同一契约。CI 现全部通过(test 6 分片 + 静态门禁全绿)。 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.634-master.930d5b4 # this exact build
npm install -g billion-context@master # always the newest merged build
|
…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).
(ai: vllm-qwen/qwen3.8-27b)
Closes #3857
What & why
Discovered while working #3823 (win32 unified-storage degrade with ZERO
[storage]lines in the log). The tee logger's fail-open design had two holes that combine into total silent log loss for launcher-spawned children:createWriteStreamopens asynchronously. A failed first open surfaced as an'error'event that only destroyed the stream — the one-shot reopen-failure warning ([warn] log file ... unavailable ... continuing with stderr-only logging) lived only ingetStream()'s try/catch and was unreachable for async failures.isFileLoggingActive()returned true for a PENDING stream whose fd had not opened yet. The [noise] 观测噪音三件:启动横幅同秒重复 24 次 / reasoning-pair-violated 每请求重报(单会话 276 条) / %TEMP% 端口日志无轮转(5 天 31.7MB) #2864 launcher mute consulted it right afterconfigureLogger(), so it muted stderr before the open result was known. On open failure: file leg dead, stderr leg muted → every subsequent line (storage warnings, engine bootstrap, everything) vanished from every sink.Fix
'error'events now route through the existing one-shot warning (warn + unmute → stderr-only fallback).onFileLegLive(fn)hook fires once per PROVEN open (fd captured); the [noise] 观测噪音三件:启动横幅同秒重复 24 次 / reasoning-pair-violated 每请求重报(单会话 276 条) / %TEMP% 端口日志无轮转(5 天 31.7MB) #2864 mute decision moved behind it.reopenWarnedreset moves from stream creation to the proven-open point — one degradation episode warns exactly once (the new test catches re-arming per doomed retry).isFileLoggingActive()now requires a captured fd.Behavior change (disclosed)
BILI_LAUNCH_TOKENset): stderr mute timing moves from "startup, stream object exists" to "log file actually opened". If the first open fails: OLD = silent forever (both sinks dead); NEW = one[warn]line on stderr + all logging continues stderr-only (which is where it's redirected to%TEMP%/bili-proxy-<port>.log).Tests
tests/logger-silent-loss.test.ts: dir-as-log-path = deterministic cross-platform ASYNC open failure (EISDIR/EPERM); worst-case pre-mute simulation; asserts one warn per episode, late lines reach restored stderr,isFileLoggingActive()===false; hook exactly-once / never-on-failure / immediate-on-late-registration.tests/logger-stderr-mute.test.tstest 1 waits for a proven open before asserting activity (old assertion encoded the racy pending-stream semantics).