Repository navigation
[PR] fix: decode zstd requests asynchronously when supported - #6489
Conversation
Register the process-spawning zstd regression in LIVE_FILES so the CI runner can start the test matrix. Append the entry to preserve existing zone slots; the child changes only its own zlib exports and binds no sockets. The actual CI runner's global registration check and all 7 zstd cases pass locally. Typecheck, build and diff checks also pass.
Retain the upstream pack-install and CI-janitor entries at their existing slots, then append the zstd fallback regression. The original decoder, benchmark and regression test blobs are unchanged. On the merged tree, the actual CI runner passes its global registration check and all 7 zstd cases. Full typecheck, production build and net diff checks pass.
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复. The only zstd-related items in the repo are #6488 (the source issue) and this PR. No prior work on asynchronous zstd decoding exists (searched open + closed issues/PRs; the author also checked all 61 Afloat16 PRs + 159 fork branches + the content-encoding commit history). Live state (verified 2026-11-13, ~07:05 UTC): head ① Direction. Issue #6488 is real and at root cause: ② Regression review. The original PR head ( Established behavior audited and preserved:
Known limitation (not a blocker): on Node 22 only, the parser trusts block sizes for frame extent; a multi-frame input with a corrupted block size that coincidentally lands exactly on the next frame's magic could be partially decoded (Node 22's native decoder does not detect the truncation). Single-frame input — the common case — always fails closed (leftover bytes → magic check throws). Requires adversarially precise corruption; not practically reachable. ③ Code. The namespace ④ Tests. Real tests with teeth: the two cancellation cases are genuine regression tests (fail on master); both gate directions are asserted (triggers: cap/abort/admission across frames; does-not-trigger: unknown-size, checksummed, interleaved skippable, RLE, and compressed frames all decode correctly); 7 truncation rejections pin the fail-closed behavior the Node 22 native decoder alone would miss; the child-process case (native factory removed via ⑤ Diff. 4 files, +264/−5, every line related to the PR's purpose. No unrelated changes, no whitespace churn, no lock-file churn. Clean. Behavior changes (flagged per policy). On native-capable runtimes (Node ≥ 22.15.0 / ≥ 23.8.0):
Auto-merge gate (§7.4): not an auto-merge candidate — behavior change (async decode, new error types) plus a hand-written binary parser; the human review tier is appropriate. Otherwise mergeable: single-module scope, regression tests in place, CI green on the rebased head, no config/persistence/wire-protocol change. Verdict: mergeable (human merge; 结构化八问
收工判定: 可合(人工合入)。CI 全绿、无冲突、回归测试真实有效;唯一真回归(Node 22 多帧/截断)已由 CI 工程师的修复 commit 收敛。 |
(ai: vllm-qwen/qwen3.8-27b) CI 已全绿。本轮 CI 工程处置摘要(head
备注: |
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).
…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).
Resolve CI baseline conflicts using the current upstream test setup.
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Review verdict: APPROVE — PR #6489 "fix: decode zstd requests asynchronously when supported" (head I did an independent end-to-end review — re-derived every conclusion from the diff plus runtime evidence on Node 22.23.2, not from the prior review comments. The fix is correct, the tests are genuine regression tests, the diff is clean, and house conventions are followed. No What I verified (independent):
Behavior changes (disclosed in the PR body, confirmed): zstd decode is now async on native runtimes (event loop unblocked; author bench 16 MiB median 63.28 ms → 0.17 ms); cancellation now works (was a no-op on the sync fzstd path); corrupt-zstd error type changed fzstd → parser/zlib (caller behavior unchanged = passthrough). No new dependency, config, or env. No small findings to fix — bit layout, reserved check, byte-cap logic, and test registration are all correct as-is. Context note (not a blocker): the owner folded #6488 into aggregation issue #6449 (root-cause performance-memory). That is a coordination decision for the owner; this review is on the PR's technical merit, which is clean. 8问(结构化审核):
结论:APPROVE — 代码正确、测试真实、diff 干净、符合仓库规范,无 |
ranxianglei
left a comment
There was a problem hiding this comment.
(ai: vllm-qwen/qwen3.8-27b)
APPROVE. Independent end-to-end review: the RFC 8878 frame parser's bit layout matches libzstd exactly (verified by flipping each descriptor bit against the native decoder on Node 22.23.2); the native decoder bugs it works around (small-frame multi-frame drop, truncated-frame acceptance) are real; the parser passed 30/30 round-trip + exhaustive-truncation across 15 frame variants; the caller's passthrough error semantics (handle.ts:516-525) are preserved; the fzstd fallback is byte-identical; the 2 cancellation tests are genuine regression tests (fail on master, pass with the fix); all 17 PR tests pass; the diff is clean (4 files, the merged-in upstream master touches none of them). No kernel/ touch, no new dep/config/env. Full 8-question review in the issue thread.
ranxianglei
left a comment
There was a problem hiding this comment.
(ai: vllm-qwen/qwen3.8-27b)
APPROVE (re-review, new head 889a403). The PR's code is byte-identical to the previously-reviewed head 1cd78a3: the new head is a merge of master (release v0.1.214, gate-recorder pipe-leak fix #6671, storage/e2e updates) that touches NONE of the PR's 4 files. Verified src/content-encoding.ts, tests/content-encoding-zstd.test.ts, scripts/bench-zstd-decode.mjs byte-identical; the live-files.mjs PR entry (content-encoding-zstd) is unchanged (the only live-files delta vs the old head is the storage-open-busy-lock entry, already on origin/master). All prior findings carry over: RFC 8878 frame-parser bit layout matches libzstd (empirically verified on Node 22), the native decoder bugs it works around are real, parser passed 30/30 round-trip + exhaustive-truncation, caller passthrough semantics preserved, fzstd fallback byte-identical, the 2 cancellation tests are genuine regression tests, all 17 PR tests pass, clean 4-file diff. No kernel/ touch. CI: 14 test shards queued on the new head (unchanged code + green master base -> expected green).
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Re-review of new head The new head is a merge of master (release v0.1.214, gate-recorder pipe-leak fix #6671, storage/e2e updates) that touches NONE of the PR's 4 files. Verified:
So the full PR contribution vs origin/master is still exactly 4 files (+264/−5), and every finding from my prior review (floor 15) carries over in full: RFC 8878 frame-parser bit layout matches libzstd (empirically verified by flipping each descriptor bit on Node 22.23.2), the native decoder bugs it works around (small-frame multi-frame drop, truncated-frame acceptance) are real, the parser passed 30/30 round-trip + exhaustive-truncation across 15 frame variants, the caller's passthrough error semantics ( CI status (new head): 14 test shards (ubuntu 22/24 ×3, windows 22 ×5) + static-gates ×2 + mysql-contract are still queued on the new head; 12 e2e/registry lanes skip by design on fork PRs, 4 static checks already green. Given the unchanged code + green master base, these are expected to land green. 8问(re-review — 代码未变,结论同 floor 15):
结论:APPROVE — 代码与已审 head 逐字节一致、无 |
|
Superseded by #6677 (merged as Landed into master via the real merge commit The fix for #6488 is now in master. Closing this PR as superseded — thanks for the careful, well-tested fix. |
Closes #6488
Problem
zstd request decoding uses a synchronous fzstd push on every supported runtime. Although the helper returns a promise, the entire compressed body is processed before the call returns. A client cancellation immediately after starting the decode is therefore ignored, and large requests occupy the server event loop throughout decompression.
Change
Use Node's native createZstdDecompress stream when available, through the same streamDecode helper used by gzip, Brotli and deflate. Validate complete Zstd frame boundaries and decode each frame asynchronously so Node 22 also preserves concatenated input and rejects truncation. This retains the existing decoded-byte limit, cumulative admission observer and abort cleanup. Keep the fzstd path when the native factory is absent, including supported older Node runtimes.
No new dependency or configuration setting is introduced. Corrupt native input remains a decode failure; it is not retried through another decoder.
Initial validation (Node 24.22.1)
Prior work and tracking
Checked all 61 Afloat16 PRs, all 159 fork branch names, the content-encoding commit history and upstream searches for zstd/native/fzstd/asynchronous decoding. #4832 adds content-encoding support to the fork-adoption gate; it does not replace the synchronous zstd decoder. No equivalent patch was found.
CI follow-up
Registered
tests/content-encoding-zstd.test.tsinLIVE_FILESin829a7853, then merged currentmaster(fcc2e848) in50926b86. The registry conflict was resolved by retaining all upstream entries at their existing zone slots and appending the zstd case. At that integration, the decoder, benchmark and regression-test files were unchanged from the previous PR head.The fallback case changes the zstd factory only inside its isolated Node child and binds no sockets. On the merged tree (Linux / Node 24.22.1), the actual CI runner passes its global process-spawn registration check and all 7 tests in the selected zstd file. Full typecheck, production build and
git diff --checkalso pass.CI run 43367878116 on
50926b86completed with the Node 22 failures addressed below.Node 22 compatibility follow-up
Commit
7341f7d1fixes the two concrete failures from Ubuntu / Node 22 shard 2 and Windows / Node 22 shard 4. Both runners used Node 22.23.4: concatenated frames returned only the first 33 bytes instead of 66, and truncated input incorrectly succeeded. The preceding Node 24 lanes passed.This matches the native decoder issues tracked in nodejs/node#64741 and nodejs/node#64592. Explicit
finishFlush: ZSTD_e_enddoes not fix the Node 22 behavior. The follow-up checks frame extents according to RFC 8878 §3.1, then sends complete frames through the existing native asynchronous decoder one at a time.The boundary walk handles variable frame headers, raw/RLE/compressed blocks, optional checksums, and skippable frames. Native zstd continues to validate compressed contents and checksums. The walk does not decompress blocks, and the next frame starts only after the preceding decode finishes. Decoded-byte accounting is cumulative across frames; overflow still reports the original configured limit, and cancellation/admission errors retain their identity. No dependency was added.
Verification of the follow-up
npm run typecheck,npm run build,npm run check:unused-exports,npm run check:test-import-graph, andgit diff --checkpass.The published tree is
929bfe6dca13059e1904df2438c6b86fc53b3708, matching the tested and independently reviewed candidate. The commit is a normal child of50926b86, which already contains upstream masterfcc2e848.Upstream validation of the final head
Upstream CI run 43375699576 completed successfully on the current PR head
7341f7d1with the default CORE matrix.The Windows / Node 22 shard 3 log records all 17/17 Zstd cases passing with no skips, including the native cancellation cases and the concatenation/truncation regressions. The full shard reports 2,643 passed, zero failed, and six unrelated tests skipped. It ran on Windows Server 2025 with Node 22.23.4 and npm 10.9.9. The file moved to shard 3 under the current workload allocation; the previously failing shard 4 also passed.
GitHub checked out test-merge commit
2f4f93efa760ae7e51e717f0b9b2fec8d39fb780, whose parents are basefcc2e848and PR head7341f7d1. Its tree is exactly929bfe6dca13059e1904df2438c6b86fc53b3708, the same tree tested locally and published above.Review status
Ready for maintainer review. Current head is
7341f7d1; refreshed hosted results are available in the Checks tab. The upstream CORE matrix on this head has passed; real-model E2E remains unverified.Please apply the existing
ci:fulllabel to run the FULL matrix, including the required Windows / Node 24 checks. The default CORE matrix does not produce those checks.