ReviewOS

home-lang/home

Bun parity: decode compressed fetch responses across transports

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

Corpus location

  • Position: 4131
  • File: js/web/fetch/fetch-gzip.test.ts
  • First observed failure: TypeError: console.trace is not a function

Required parity

  • Implement console.trace with useful stack output without disrupting fetch execution.
  • Transparently decode buffered, redirected, streamed, and multi-chunk gzip responses.
  • Resolve relative and protocol-relative redirects correctly while preserving url, redirected, and status metadata.
  • Match content codings case-insensitively, including x-gzip, plus deflate, Brotli, and Zstandard.
  • Leave unknown content encodings untouched.
  • Treat zero-byte compressed responses as empty for both chunked and Content-Length: 0 framing.
  • Preserve decompression across large bodies and raw TCP framing without hidden fixed output limits.
  • Surface malformed or failed decompression through structured errors with codec, operation, response, cause, and composed stack context.

Completion gate

  • Make the complete copied Bun corpus file pass, apart from explicit upstream todos if any.
  • Add focused regressions and pin the file in the permanent HTTP/web mini-suite.
  • Keep copied-corpus accounting and the project build green.

Parent tracker: #66

10 days ago

Completed in d8ff2b203 (fix(fetch): decode compressed responses).

Implemented:

  • Native gzip and zlib response decompression callbacks backed by std.compress.flate, with unlimited output rather than a hidden fixed cap.
  • Case-insensitive gzip, x-gzip, deflate, br, and zstd response decoding; unknown encodings pass through and zero-byte encoded bodies remain empty.
  • Binary-safe fs.readFileSync, Bun.file().arrayBuffer(), Bun.file().stream(), Node HTTP response chunks, and raw TCP response parsing.
  • Buffered, redirected, streamed, multi-chunk, and modeled >1 GiB response paths.
  • console.trace() stack output.
  • Structured decompression errors carrying code, operation=fetch.response.decompress, encoding, cause, and a composed stack.
  • Focused regression coverage plus a permanent HTTP/web queue pin.

Verification:

  • js/web/fetch/fetch-gzip.test.ts: 24 passed, 0 failed, 0 todo, 0 unsupported.
  • Positions 4131–4132 together: 39 passed, 0 failed, 0 todo, 0 unsupported.
  • Permanent HTTP/web tail queue: passed.
  • zig build --cache-dir /private/tmp/home-zig-abi-cache: passed.

The verified frontier now runs through position 4132. Follow-up HTTP/2 compressed request-body work is tracked in #355.

Sign in to comment on this issue.