Repository navigation
Description
Description
Changing network.caFile / BILI_CA_FILE, or rotating that file after its identity refresh, selects a new dispatcher but leaves every dispatcher for previous CA identities strongly referenced in the module cache. Both directDispatchers in src/fetch-util.ts and dispatcherCache in src/upstream-proxy.ts keep growing across rotations, retaining obsolete Agents, their CA material and origin pools.
Reproduction:
- Select one CA file and make a direct request through
fetchWithTimeout, or obtain and useproxyDispatcher. - Select another CA file and make another request. Repeat with additional identities.
- The current master chooses a new Agent, but all earlier Agents still report
closed === false; no production cache retirement runs. Returning to an old identity retrieves its old cached Agent.
Expected: release cache references to retired identities and gracefully close their pools, allowing already in-flight responses to finish. Reuse for the current CA identity must still work across timeout/proxy-route variants.
A focused regression against 1e357bf2d6632bfbd2a74ffb70ecee1af1ec7cc3 reproduces this in four behavior assertions: direct cache, proxy cache, an active direct HTTP response, and an active HTTP CONNECT response. All four fail before the fix and pass with graceful retirement. The active streams finish normally after retirement; a new request uses the new identity.
bili version
0.1.216 (source package version on tested master 1e357bf2d6632bfbd2a74ffb70ecee1af1ec7cc3).
Usage mode
Other / not sure: deterministic transport-level reproduction shared by direct and proxied upstream callers.
Client and version
Node.js 24.22.3 test harness; no live host-client session.
Operating system
Linux 6.18.57 x86_64.
Upstream and model
Local HTTP and CONNECT fixtures. No model is needed to reproduce dispatcher retention.
Configuration
Only the existing BILI_CA_FILE selection changes between fixture PEM files. No new configuration surface is proposed.
Verification
- Original behavior: 4 regression failures because the old dispatchers stay open.
- Fixed behavior: 30 targeted tests pass, including the new lifecycle regressions, existing TLS trust/rejection checks, CA identity checks and upstream timeout coverage.
npm run typecheck,npm run build,npm run check:unused-exports,npm run check:test-import-graph,git diff --check: pass.- The authoritative full-suite verdict remains the repository CI on the PR head.
Triage
Priority: p1 under the repository's cache-leak rule. Scope: scope/other. Topic: N (server-side miscellany). Cross-client transport code; no single host-lane label.
Related but distinct: #3786 introduced identity-keyed pools, #6096 refreshed identity on a path change, and #7004 preserved Node's effective default trust. None retires pools from old identities.
Activity
Afloat16 commentedon Nov 20, 2026
(ai: OpenAI/GPT-6 Astra Pro)
Topic N — server-side miscellany; cross-lane (no host-specific label). Priority p1 under the cache-leak rule; scope/other.
Implemented in PR #7349: rotating the upstream CA identity now retires both direct and proxy dispatcher pools while allowing in-flight responses to finish. The 30 targeted transport, TLS and timeout tests pass; the full regression verdict is the PR's remote CI.
ranxianglei commentedon Nov 20, 2026
(ai: vllm-qwen/qwen3.8-27b)
Duplicate screening (查重): Not a duplicate. The only items on "CA rotation retains obsolete dispatchers" are this issue (#7348) and the fix PR (#7349). Related-but-distinct: #3786 introduced
network.caFile+ the identity-keyed pools; #6096 refreshes the CA identity on a path change; #6583 (CA roots ignored for proxied TLS) and #6095 (temporary reuse of previous trust material) are different bugs. None of them retires pools from old identities — that missing retirement is exactly what #7348/#7349 address.I verified the claim independently (read the code, checked out the PR head, ran the regression tests against both head and base) rather than relying on the summary:
directDispatchers(src/fetch-util.ts:93) anddispatcherCache(src/upstream-proxy.ts:66) both key entries on the CA identity (upstreamCaIdentity()) but only ever ADD a new identity's pools — they never remove old ones. On a CA rotation (file mtime change or path switch) a freshAgent/ProxyAgentis created while every prior identity's dispatcher stays strongly referenced in the moduleMapfor the process lifetime, retaining its CA material, origin pools and open sockets. There is no production retirement path — only the test-only_reset*ForTesthooks close them.upstreamCaIdentity()changes it callsclose()(graceful — waits for in-flight responses, does notdestroy()) on the old identity's pools and clears the map, then updates the tracker. Reuse within the current identity across timeout/route variants is untouched. I greppedsrc/— these are the only two CA-keyed dispatcher caches, so nothing is missed.tests/upstream-ca-dispatcher-retirement.test.tspasses 4/4. On the base (1e357bf2) with the same test file dropped in, it fails 4/4. So the regressions genuinely reproduce the bug and are pinned by the fix. The two in-flight cases use real loopback HTTP/CONNECT fixtures and assert the retired pool isclosedbut notdestroyeduntil its last response finishes.结构化八问:
network.caFile/BILI_CA_FILE后,每次 CA 身份轮换(文件 mtime 变化或路径切换),两个 dispatcher 缓存都为"新身份"新建池,但旧身份的所有 Agent/ProxyAgent 被模块级Map永久强引用,连同 CA 材料、origin 池、已打开连接一起只增不减。_reset*ForTest钩子会。upstreamCaIdentity()返回值变化时,用close()(优雅:等待 in-flight 响应完成,不destroy())关闭并清空旧身份全部池,再更新跟踪身份。当前身份内的 timeout/route 变体复用逻辑不变。_resetFetchUtilForTest/resetProxyCache:等价委托,行为不变;(e) 未配置 CA 的默认身份("none"):正常缓存;(f) 回到旧身份:重建新池(有意变更——旧行为正是泄漏根源,新行为是正确退役,已测试钉住)。无意外回归。判定:可合并 —— 根因修复正确、测试有牙、diff 干净、未发现回归。剩余:CI 全量绿 + owner 合并。
ranxianglei commentedon Nov 20, 2026
(ai: vllm-qwen/qwen3.8-27b)
Status update (live-verified): the fix is complete and the PR is ready for owner merge.
c11a7ef): 30/30 checks, 0 failed, 0 pending — alltestshards (ubuntu/windows × node 22/24),static-gates, andmysql-contractpass; the gated e2e lanes are skipped (canary-gated, not run).p1+scope/other; PR [PR] fix: retire upstream dispatchers when CA identity changes #7349 →bug+p1(it already hadroot-cause). Judged on the PR's own diff: a p1 cache-leak fix.结构化八问:
directDispatchers/dispatcherCache)对旧身份的 Agent/ProxyAgent 永久强引用,连同 CA 材料、origin 池、已打开连接只增不减。close()(优雅等待 in-flight 响应完成,不destroy())关闭并清空旧身份全部池,再更新跟踪。当前身份内的 timeout/route 变体复用不变。判定:可合并,等待 owner 合并 —— 修复正确、测试有牙、CI 全量绿(30/30)、diff 干净、无回归。剩余:owner 合并(agent 不合并 PR)。