Guides
Streaming binary data
Return a BinaryStream and consume it with invokeStream — real backpressure.
Command results are JSON envelopes capped at 1 MiB. For files or exports, return a BinaryStream and consume it with invokeStream — a pull-based protocol with real backpressure. Verified live at 2 GiB on macOS.
import { invokeStream } from "jdesk-client";
const result = await invokeStream("media.export", { id: 42 });
const reader = result.stream.getReader();
for (;;) {
const { done, value } = await reader.read();
if (done) break;
consume(value);
}
Each read() issues one pull for up to chunkBytes (256 KiB max) — the runtime never sends data the page has not asked for.