Repository navigation
[PR] fix: preserve cancellation across native Request reconstruction - #6556
ranxianglei merged 14 commits into
Conversation
(ai: vllm-qwen/qwen3.8-27b) Duplicate screening (查重): not a duplicate. PR #6556 is the only open PR touching I reviewed the diff independently against the code and ran the tests both ways rather than taking the local-pass claim at face value. The fix is correct and complete. I verified the signal-linking semantics empirically on Node 22:
The tests have teeth. Ran the new suite both directions:
Base & hygiene. The PR sits on the current master ( CI status (verified live). The PR head's 4 failing test shards (ubuntu 22/24 shard 3, windows 22 shard 3/5) are the inherited master failures from #6547 ( 结构化八问
判定:修复正确、完整、测试有牙(基线 8 红 / 修复后 12 绿,双向实测)、diff 干净、基于当前 master、无热文件冲突。代码层面满足 auto-merge 门禁各项,唯一未满足的是 CI 绿——而 CI 红是继承性失败(#6547,由在途 #6561 修复,非本 PR 引入)。代码可合;合并动作按规则由人工执行。CI 转绿路径:等 #6561 合入后重跑即可(或确认 |
[bot] 进度汇报:评审已完成,无阻塞。 刚才那段时间不是卡死,是在做本地定向验证( 结论一句话:代码可合——修复正确、完整、测试有牙(基线 8 红 / 修复后 12 绿,双向实测)、diff 干净、基于当前 master、无热文件冲突。唯一未满足的 auto-merge 门禁是 CI 绿,而 CI 红是继承性失败(#6547,由在途 #6561 修复,非本 PR 引入)。合并动作按规则由人工执行;CI 转绿路径 = 等 #6561 合入后重跑。 |
[bot] 🏷 最终状态(live 复核线程后确认,评审已完成):
合并动作按规则由人工执行;CI 转绿后本 PR 即满足全部门禁。 |
The suite baseline preload (preload-storage-baseline.mjs) pins BILI_STORAGE_UNIFIED="legacy" for the broad corpus. After ranxianglei#6480 flipped the storage default to pure-sqlite, the notice-registry suite's visibleNotices assertions expect the pure-sqlite default notice, which is gated on unifiedSelectionIsSqlite (unified "sqlite" or absent) — the preload's "legacy" made the notice silent, so the suite was born-red on master. Pin the selection explicitly (ranxianglei#4011 lesson: a test that depends on the production default passes locally but fails in CI).
(ai: vllm-qwen/qwen3.8-27b) CI diagnosis: the PR is innocent — all 4 red shards are inherited from master, not caused by this PR's diff. I re-verified the live check state (still red on head Root cause (confirmed by local A/B repro):
The fix is already converged in ci-fixes — sentinel commit Blocker — I cannot push to this PR's branch. The head lives in the external fork Action needed from the PR author (one command set, then CI re-runs green): The notice-registry failures clear from the ci-fixes pin; the Windows EBUSY flake clears on re-run. 八问(中文):
|
[bot] 🏷 CI fix run summary (attempt 1/3) Diagnosis: All 4 red shards are inherited from master, not caused by this PR's diff.
Fix: Already converged in ci-fixes — sentinel commit Blocker: I merged ci-fixes locally (merge Action needed from PR author: Verified: Root cause confirmed by local A/B repro (with preload → 2 red; without → 5/5 green). Fix verified by sentinel (5/5 both regimes). |
…test The dsh plugin lane (ci-e2e-dsh.yml) runs node --import tsx --test WITHOUT the preload-storage-baseline.mjs preload, so BILI_STORAGE_UNIFIED is unset and the storage mode defaults to 'full'. Under the pure-sqlite default flip (5a80e2b, ranxianglei#6480), 'full' mode turns the JSON envelope writer OFF — so the .content-store.json sidecar is never written, and the test's readdirSync(namespace) hits ENOENT. Pin BILI_STORAGE_JSON_WRITER=on in the test so the content-store sidecar is written regardless of the storage mode. This keeps the corrupted-store detection path exercised in both full and legacy modes. Closes: dsh plugin lane red on master (run 43532980164, job 132255459726)
The pure-sqlite default flip (5a80e2b, ranxianglei#6480) turns the JSON envelope writer OFF, so the .json session file this lane asserts on is never written and 'proxy must persist the session' / 'no persisted session carried compressed blocks' fail after the 20s wait. Pin the writer ON in the spawned client's env (the bootstrapped proxy inherits it) so the envelope this test was written for is still produced. Closes: native opencode lane red on master (run 43547593803, job 132302438610)
Same pure-sqlite default flip (5a80e2b, ranxianglei#6480) as the opencode lane: the JSON envelope writer is OFF, so 'proxy must persist the session within 20000ms' fails — the on-disk .json session file is never written. Pin the writer ON in the spawned dsh client's env (the bootstrapped proxy inherits it). Closes: native dsh lane red on master (run 43547497015, job 132302138843)
…e2e lane Same pure-sqlite default flip (5a80e2b, ranxianglei#6480) as the opencode/dsh lanes: the JSON envelope writer is OFF, so 'session persisted' fails — the on-disk .json session file is never written. Pin the writer ON in the spawned pi client's env (the bootstrapped proxy inherits it). Closes: pi codex-responses WS lane red on master (run 43547626291, job 132302540960)
…lane 4th lane of the pure-sqlite default flip (5a80e2b, ranxianglei#6480) family: the JSON envelope writer is OFF, so 'proxy must persist the session' and 'at least one persisted session must carry compressed blocks' fail — the on-disk .json session file is never written. Pin the writer ON in the spawned pi client's env (the bootstrapped proxy inherits it). Closes: pi package-native lane red on ci-fixes (run 43558179054, job 132336647955)
Same pure-sqlite default flip (5a80e2b, ranxianglei#6480) family: the JSON writer is OFF, so the per-session CCR content-store sidecar (.content-store.json) that 'child persists its own companion and survives a proxy restart' asserts on is never written (0 !== 1). The earlier b1bc17b pin only covered tests/plugin-fork.test.ts, not this file. Pin the writer ON at module load (before any SessionStore is constructed). Closes: dsh plugin lane red on ci-fixes (run 43558179102, job 132336519539)
…lane Pure-sqlite default flip (5a80e2b, ranxianglei#6480) family: the JSON envelope writer is OFF, so 'proxy must persist the session' fails — the on-disk .json session file is never written. Pin the writer ON in the spawned opencode client's env (the bootstrapped proxy inherits it).
Pure-sqlite default flip (5a80e2b, ranxianglei#6480) family: the JSON envelope writer is OFF, so the on-disk .json session envelope this lane asserts on (exactly ONE persisted session under the raw key) is never written. Pin the writer ON in the spawned dsh client's env.
Pure-sqlite default flip (5a80e2b, ranxianglei#6480) family: the JSON envelope writer is OFF, so the on-disk .json session file this lane asserts on (state survival across the OLD→NEW update) is never written. Pin the writer ON in the spawned proxy's env (both update phases share envBase).
|
Current head I verified this exact head on Linux / Node 24.22.1: 27 tests passed, 0 failed, 0 skipped — 12 native cancellation cases, 8 adjacent inline cases, 5 notice-registry cases, and the 2 upstream in-place-update regressions. The repository's storage/test-environment/zone preloads were used; its existing registry-fetch test seam kept the optional catalog refresh offline, while the loopback HTTP fixtures ran normally. Exact-head manifest and test log. The fresh upstream CI run is still pending. This local result does not establish a Windows or full-matrix pass; the Windows handle-teardown work in #6561 remains open. |
[bot] 🏷 Verified the new head I fetched the new head from the fork and confirmed:
The mirror cache is still showing the old head ( |
ranxianglei
left a comment
There was a problem hiding this comment.
(ai: vllm-qwen/qwen3.8-27b)
APPROVE — independently re-verified (direct Node probes + both-direction test runs), not taken from the thread.
Head note: the fork branch has advanced past the head this task pinned — e49d4b73f → now 3d226753 ("Merge upstream master and converge CI test fixes"). The two feature files (src/agent/native-intercept.ts, tests/native-request-signal.test.ts) are byte-identical across that range, so the verification below holds for both heads. The new commits are all master-origin (release v0.1.214, #6671, #2195, CI test pins) — a standard master/ci-fixes refresh, not new PR work. (A 9-space indent slip in e2e-native-pi.test.ts from an earlier ci-fixes pin is already corrected at the new head.)
Correctness. The four field-form Request reconstructions now carry signal: withHeaders (src/agent/native-intercept.ts:433), replaceRequestTarget streamed-body fallback (:1455), replaceRequestPayload (:1473), withRestoredBody try (:1492) + catch (:1498). I probed Node directly: the two object-form sites (:1439, :1645) already link the signal (abort propagates with the same reason), so they were correctly left untouched. I enumerated all six new Request( sites — no field-based reconstruction was missed.
init.signal precedence preserved. withRestoredBody's catch path init?.signal !== undefined ? init.signal : input.signal keeps fetch's override, including a null override (probed: original aborted → effective stays un-aborted; a replacement signal aborts with its own reason; undefined inherits the base).
Tests have teeth. tests/native-request-signal.test.ts (12 cases: 3 real-loopback lanes rewrite/routed/self — abort only after the server receives the request, assert the caller's reason rejects the actual request; 6 replacement cases pre-/later-aborted; 2 init.signal override controls; 1 streamed-body fallback). On the unfixed base: 8 fail / 4 pass (the 4 controls are the two object-form target cases + the two override cases, already correct pre-fix). With the fix: 12/12. Related suites (native-intercept, issue3304-incremental-direct-send) green (116).
Diff/scope. Feature files = the core commit. The storage-test env pins in the diff are the sanctioned ci-fixes merge (same SHAs as origin/ci-fixes) clearing the inherited master red (#6547) — not author noise. No config / persistence / wire-message-shape / kernel change; the signal is a transport control channel, request bytes untouched.
结构化八问
- 是什么问题:native 拦截器在盖插件头、换增量 body、恢复全量 body、重定向 target(含流式兜底)时逐字段重建 Request,漏拷调用方 AbortSignal——取消生成后实际出站请求仍跑完。
- 什么原因导致的:四处「逐字段重建」
new Request(url,{method,headers,body,…})省略signal,产出全新永不 abort 的 signal(实测源 abort 后克隆不 abort);两处「对象重建」new Request(url,req)本身链接 signal(实测同 reason 传导)故不受影响。根因=逐字段重建丢取消信道,不是 signal 机制本身有缺陷。 - 影响范围与严重程度:native 三条路由(rewrite/已路由/self)上盖头、增量 payload、恢复 body、流式 target 兜底全部路径 + spawn transport + 进 inline engine 的请求。严重度:取消被静默忽略、请求继续耗上游算力/成本——可用但有明显问题,p2 合理(非缓存泄露类,不升 p1)。
- 怎么修复的:四处逐字段重建补
signal:<原>.signal;withRestoredBodycatch 按init?.signal !== undefined ? init.signal : input.signal保留 fetch 的 init.signal 覆盖优先级(含 null);两处对象重建不动(已自动链接)。 - 是否有回归问题:无。唯一行为变化=signal 现在被保留(正是修复目标);基线 4 个对照(对象重建 target ×2、init.signal 覆盖 ×2)修复前后都过,证明这些路径行为未变;body 字节/插件头/路由/压缩行为不变;init.signal 覆盖(含 null)实测仍按 fetch 语义。
- 是否破坏缓存:不涉及。signal 是传输层控制信道,不进被缓存的消息内容;不影响缓存/重试/增量游标/去重键。
- 是否改了设计方向:不涉及。native-intercept 模块内传输层修复,无架构/边界/数据流转向。
- 是否引入了新的配置:不涉及。无新 env/config/默认值。
判定:修复正确、完整、测试有牙(基线 8 红 / 修复后 12 绿,双向实测)、功能文件=核心 commit、存储测试钉值来自 ci-fixes 合并(非作者噪声)、无热文件冲突、无 kernel/配置/线格式变更。代码可合;合并动作按规则由人工执行。
(ai: vllm-qwen/qwen3.8-27b) ✅ Review done — posted APPROVE on PR #6556 (independently re-verified: fix correct+complete across all 4 field-form Request reconstructions, |
[bot] 🏷 PR #6556 reviewed — APPROVED (GitHub review id 5903340462) Fix verified correct & complete. The change preserves the caller's Verification (independent, not copied from prior thread):
Scope: The 8 storage-test env pins are the sanctioned Head note: Fork branch advanced Merge is human-only per policy. 八问审核清单(中文)
判定:APPROVE,可合(合并按策略由人工执行)。 |
|
Superseded by #6677 (merged as Landed into master via the real merge commit The fix for #6555 is now in master. Closing this PR as superseded — thanks for the careful, well-tested fix. |
[bot] 🏷 Acknowledged — PR #6556 closed as superseded by #6677 (merged as |
Fixes #6555
Problem
Native interception stamps headers and replaces incremental/restored request bodies by constructing a new Request from selected fields. The caller's signal is omitted, so cancelling a generation stops controlling the actual outbound request. This affects spawned transport as well as requests entering the inline engine.
Changes
Preserve the original Request signal when stamping headers, replacing payloads, restoring full bodies and rebuilding a streamed target after the ordinary constructor fails. Explicit init.signal replacements and null overrides keep their existing fetch precedence.
Validation
e1f31ad9d5b47500362699a9867819b861c7de96, the 12-case regression suite reports 8 failures and 4 passing controls.Related history and scope
The maintainer review of #6504 identifies the header-stamping defect. That PR changes the inline dispatcher's signal lookup; this patch preserves the signal before it reaches any transport. Checked all 71 Afloat16 PRs, open PR metadata and all-state searches for withHeaders, Request signals and cancellation. No existing native-constructor fix was found.
The change preserves body bytes, plugin headers, request routing and compression behavior. It introduces no configuration, persistence or kernel change.
Remote CI follow-up (2026-11-13)
CI run 43456733438 is failed, not green. I inspected every failed test job: Ubuntu Node 22/24 report the two
notice-registry.test.tsassertions for the sqlite-default notice; Windows Node 22 additionally reportsEBUSYwhile deletingindex.dbinpersist-zstd.test.tsandpersist-metadata-fold-gate.test.tsteardown. None of the changed files owns those paths. On the unchanged basee1f31ad9d5b47500362699a9867819b861c7de96, running the notice suite with the exact CI preload chain reproduces 3 passed / 2 failed (without the legacy-storage preload it is 5 passed / 0 failed).Existing upstream PR #6561 / issue #6547 covers these same storage-baseline and Windows-handle failures. This PR keeps its focused product change separate; its full CI verdict remains failed until the upstream test fixes land and the head is rechecked. Windows reproduction here is limited to the remote job logs.