Skip to main content

Streaming and asynchronous jobs

Streaming to the browser

A Route Handler can forward the streaming API directly as ReadableStream, without buffering the entire document in server memory:
app/api/convert/stream/route.ts
On the client, consume the response with ReadableStream native or a streaming library of your choice:
Server Actions do not support response streaming (they are serialized RPC calls, not raw Response calls). For actual streaming to the client, use a Route Handler.

Jobs due to saturation (202) in Server Actions

The convertFormData and convertUrlAction helpers inherit autoPoll from SDK of Node.js (enabled by default): if the server responds 202, the Server Action waits internally for the poll and returns the final Markdown once completed.
app/actions.ts
Server Actions have their own platform timeout (varies depending on your hosting provider). If you expect conversions that may take several minutes due to saturation, consider a Route Handler with manual polling from the client instead of blocking the Server Action.

Manual poll from the client

app/api/jobs/[id]/route.ts
Under normal load conditions you won’t see 202 — it only happens when all backends are saturated. The automatic poll of convertFormData/convertUrlAction already covers it for most cases.