ReviewOS

zig-utils/zig-js

Fetch: preserve ReadableStream body lifecycle

#407
Closed chris opened this 9 days ago ·
9 days ago

Parent: #406 Related: #405, #141 Roadmap: #134

Make Fetch Body objects preserve engine-native ReadableStream bodies instead of stringifying them at construction. This is the required body lifecycle beneath WebAssembly streaming compilation.

Scope

  • Store stream bodies as managed Value edges on Response and Request without eager consumption.
  • Expose realm-correct body and derived bodyUsed; distinguish null, buffered, locked, disturbed, closed, errored, and cancelled bodies.
  • Route text, JSON, ArrayBuffer, bytes, Blob, and FormData body methods through the same #405 consumer machinery.
  • Reject repeated, locked, errored, detached, invalid-chunk, and abrupt-pull consumption through returned Promises.
  • Preserve Content-Type inference, cloning rules, sibling realms, GC relocation, cancellation, and failure atomicity.
  • Add focused Debug, ReleaseSafe, and TSan tests without running unrelated long corpora.
  • Document the exact lifecycle contract and close only after fixing-main CI is green.
9 days ago

Implemented on main in 54bbb14c (stream-preserving Fetch Body lifecycle, tee/clone/transfer mechanics, focused runtime coverage) and a35f025e (pinned Home/Bun contract, audit validators, docs, and Debug/ReleaseSafe/TSan CI commands). Local focused Fetch Body and underlying ReadableStream matrices pass in all three modes with zero leaks. Closure remains gated on the exact fixing-main job.

9 days ago

Exact fixing-main CI is green, including the complete private-ABI boundary: https://github.com/zig-utils/zig-js/actions/runs/29785272707/job/88495394827

Sign in to comment on this issue.