Skip to content

ABI: implement readable-stream consumption and conversions #405

Description

@chrisbbreuer

Parents: #140, #143
Profiles: #163, #164
Roadmap: #134

Implement the six pinned readable-stream consumption boundaries on top of a real Web Streams state machine. This is not a permission to accept an arbitrary array/iterator as a stream: the exported ABI must preserve locked, disturbed, cancellation, chunk, and Promise behavior.

Scope

  • Pin Home 7ed99c02, Bun 4982b91e, ReadableStream.cpp, generated builtin behavior, and exact source identities.
  • Implement realm-local ReadableStream, default reader, controller, queue, close/error/cancel, lock release, and disturbed state needed by the pinned consumers.
  • Consume synchronously and asynchronously enqueued chunks in order without invoking user code while engine/GC locks are held.
  • Implement ZigGlobalObject__readableStreamToArrayBuffer with exact byte concatenation, detached/view bounds, overflow, rejection, and Promise identity.
  • Implement ZigGlobalObject__readableStreamToBytes as the pinned Uint8Array result without an avoidable second payload copy.
  • Implement ZigGlobalObject__readableStreamToText with streaming UTF-8 decoding, split sequences, BOM/error behavior, and lone-surrogate safety.
  • Implement ZigGlobalObject__readableStreamToJSON through the engine JSON parser, with decode/parse failures delivered through the returned Promise.
  • Implement ZigGlobalObject__readableStreamToBlob with exact byte/type ownership and Blob integration.
  • Implement ZigGlobalObject__readableStreamToFormData for pinned multipart and URL-encoded content types, boundaries, filenames, binary values, duplicates, and malformed bodies.
  • Preserve locked/already-consumed/errored/cancelled streams, abrupt pull/cancel callbacks, empty bodies, mixed/invalid chunks, sibling realms, invalid encoded handles, and OOM/failure atomicity.
  • Add bounded Home/Bun Debug, ReleaseSafe, and TSan fixtures; refresh inventories, concise README counts, docs, and roadmap evidence.
  • Close only after the exact fixing main CI job is green.

No placeholder resolved Promise, eager whole-source shortcut, or host-only stream shape. All six exports must consume the same engine-native stream machinery that JavaScript observes.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions