Pre-launchTallrig is being built in the open and is not yet open for production customers. General availability: late 2026 – 2027.
Tallrig
Colour theme
Sign inRequest access
6 steps · 4 min

Stream responses from your app

Server-Sent Events, streamed pages and long-running requests: what reaches your visitor, the time limits, and the headers your app receives.

  1. Send your headers first, then streamReturn the response as soon as the work starts and write to it as you go. Each chunk is forwarded to the visitor as your app sends it; nothing in between waits for the whole body. For Server-Sent Events use Content-Type: text/event-stream and Cache-Control: no-cache.
  2. Know the three limitsYour app has 240 seconds to start its answer (status and headers), counted from the last byte of the request. After that, a response may run for as long as it keeps sending: there is no total limit. A connection that carries no bytes at all for 240 seconds is closed, so a slow upload or a slow download is fine as long as it keeps moving.
  3. Keep long streams alive and let clients reconnectSend something at least once a minute on a long stream; an SSE comment line is enough. Networks between your visitor and your app often allow less silence than we do. A stream also ends when you deploy a new version, so have the client reconnect: EventSource does that for you, a fetch reader needs its own retry.
  4. Do not compress in your appRequests reach your app with Accept-Encoding: identity. Compression for the visitor is applied at the edge, flushing as your app flushes, so a compression middleware in your app only adds a buffer in front of your stream.
  5. Your app sees its own hostname; the visitor's address is in the forwarded headersX-Real-IP and X-Forwarded-For both carry the visitor's address, as one value; whatever the visitor sent in those headers is discarded at the edge. Host and X-Forwarded-Host are both the public hostname the visitor used, and X-Forwarded-Proto is https, so redirects and links that read Host work unchanged.
  6. Tell our errors from yoursAn error page written by Tallrig carries the header x-tallrig-proxy-error. 504 with upstream-timeout means your app accepted the request and did not start an answer within 240 seconds. 502 with upstream-unreachable means nothing accepted the connection on your app's port, usually because it is restarting. A 502 or 504 without that header came from your own code. WebSockets are not carried yet; use Server-Sent Events with POST.
A streaming route handlerts
export async function POST(request: Request) {
  const encoder = new TextEncoder();
  const stream = new ReadableStream({
    async start(controller) {
      controller.enqueue(encoder.encode("event: status
data: started

"));
      const keepAlive = setInterval(
        () => controller.enqueue(encoder.encode(": keep-alive

")),
        30_000,
      );
      try {
        for await (const step of runTheJob(request.signal)) {
          controller.enqueue(encoder.encode("data: " + JSON.stringify(step) + "

"));
        }
      } finally {
        clearInterval(keepAlive);
        controller.close();
      }
    },
  });
  return new Response(stream, {
    headers: { "content-type": "text/event-stream", "cache-control": "no-cache" },
  });
}

All guides

Ready to build?

Signups are invite-only right now — request access and we'll follow up.

Request accessRead the docs