ReviewOS

home-lang/home

Bun parity: implement complete fetch body compression semantics

#352
Closed chris opened this 10 days ago ·
10 days ago

Corpus location

  • Position: 4128
  • File: js/web/fetch/fetch-compress.test.ts
  • First observed failure: string body: Expected 1047 to be less than 1041

Required parity

  • Compress eligible string, typed-array, Blob, and file bodies with gzip, deflate, Brotli, and Zstandard.
  • Support compress: true as gzip and { encoding, level } with valid per-codec levels.
  • Leave bodies uncompressed for compress: false, an explicit Content-Encoding, streams, and empty bodies.
  • Set Content-Encoding and exact compressed-byte Content-Length headers.
  • Handle bodies above the shared-buffer threshold, including incompressible spill paths and zlib-wrapped streaming deflate.
  • Recompress the original body correctly for method-preserving redirects.
  • Reject unsupported encodings and invalid levels before transport work using structured errors with stable code, operation, codec/level context, cause, and composed stack.

Completion gate

  • Make the complete copied Bun corpus file pass.
  • Add a focused regression and pin it in the permanent HTTP/web mini-suite.
  • Keep the full copied-corpus accounting and project build green.

Parent tracker: #66

10 days ago

Implemented and pushed to main in 767e563fac42ef8f014e51c51e480c53d48cd2b7.

  • Added gzip, deflate, Brotli, and Zstandard request compression for strings, typed arrays, Blobs, and file bodies.
  • Supports compress: true, explicit encodings, object form with validated levels, exact encoding/length headers, empty/stream/explicit-header skip behavior, large bodies, spill paths, and method-preserving redirects.
  • The prepared body is shared across local, raw TCP, proxy, and HTTP/2 transports; redirects retain the original body for recompression.
  • Compression failures expose ERR_FETCH_COMPRESSION, fetch.request.compress, codec/level/property context, a cause, and a composed stack.
  • Fixed double byte normalization that could encode decimal byte text instead of the original payload.
  • Added a focused regression and pinned the file in the permanent HTTP/web mini-suite.

Verification:

  • js/web/fetch/fetch-compress.test.ts: 32 passed, 0 failed, 0 todo, 0 unsupported
  • focused compression regression: passed
  • permanent HTTP/web tail queue: passed
  • clean zig build --cache-dir /private/tmp/home-zig-abi-cache: passed

Sign in to comment on this issue.