Skip to content

perry-stdlib: ReadableStream / Web Streams API not implemented #320

Description

@proggeramlug

What happened

After Effect compiles past codegen (post #309 / #310), the link step fails with:

Undefined symbols for architecture arm64:
  "_js_readable_stream_new",
      referenced from: <Effect's Stream module>
  "_js_readable_stream_controller_close",
  "_js_readable_stream_controller_enqueue",
  "_js_readable_stream_controller_error",

These are 4 FFI symbols that perry-codegen emits calls to but perry-stdlib does not provide. They correspond to the WHATWG ReadableStream constructor + controller methods.

What you expected

Either:

  1. Implement ReadableStream in perry-stdlib (alongside fetch, URL, etc. from the WHATWG family). Effect's Stream module — and any Node 18+ code touching fetch().body — needs this.
  2. Detect at codegen time that no implementation exists and either emit a clear "ReadableStream not yet supported" error at the call site, or fall through to a runtime stub that throws on use rather than producing a link error.

Likely fix site

  • Codegen emits these symbols in crates/perry-codegen/src/lower_call.rs (search for js_readable_stream_) and / or wherever ReadableStream resolves as a built-in.
  • Implementation belongs in crates/perry-stdlib/src/streams.rs (new file), modeled after fetch.rs / buffer.rs for the FFI shape.
  • Real ReadableStream implementation is non-trivial (backpressure, queuing strategies, async iteration). A minimum-viable implementation matching Node 18's node:stream/web surface is the right scope.

Minimal reproduction

const stream = new ReadableStream({
  start(controller) {
    controller.enqueue("hello");
    controller.close();
  }
});
console.log(stream);
perry compile repro.ts -o /tmp/out
# fails at link with: Undefined symbols: _js_readable_stream_new, ...

Environment

  • Perry version: 0.5.405
  • Host OS: macOS 26.4 (arm64)
  • Target: native
  • Effect version: 3.21.2 (where this surfaced)

Adjacent gaps to consider in the same fix

While doing the WHATWG-streams audit, also check:

Discovered as part of the #309 long tail.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed defect or regression

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions