Skip to content

Document (and let endpoints relax) the server timeouts that cut off long HttpApi streams #9683

Closed

Description

@fubhy

Problem

HttpApi can now stream in both directions: StreamUint8Array and StreamNdjson request payloads (#9575), and StreamSse, StreamNdjson and StreamUint8Array responses. With default server settings, two runtime timeouts end these streams early. Neither is mentioned in the HttpApi docs or in the server layers' JSDoc.

Node: requestTimeout, 300 seconds by default. Node's http.Server limits how long it takes to receive the whole request. A streamed upload, or a two-way streaming session, that runs past five minutes gets a 408 and the connection is closed.

NodeHttpServer.layer(() => createServer({ requestTimeout: 1000, connectionsCheckingInterval: 100 }), { port: 0 })
// endpoint: payload StreamUint8Array; the client uploads 30 chunks, 100 ms apart
// => HttpClientError: Decode error (408 POST .../upload)

Bun: idleTimeout, 10 seconds by default. Bun.serve closes a connection when no data has moved for 10 seconds, so an event feed that is quiet for that long gets closed.

BunHttpServer.layer({ port: 0 })
// handler: Stream.make(1, 2), then one more element after 12 s
// Bun: [Bun.serve]: request timed out after 10 seconds. Pass `idleTimeout` to configure.
// client: HttpClientError: ... The socket connection was closed unexpectedly

Both defaults are sensible for ordinary requests, and short tests never reach them. That is why this only shows up in production.

Proposal

  1. Document both timeouts in the streaming sections of the HttpApi docs and in the NodeHttpServer.layer and BunHttpServer.layer JSDoc, with the trade-offs:
    • Node: createServer({ requestTimeout: 0 }) or a larger value. This applies to every route, because Node has no per-request setting.
    • Bun: idleTimeout up to 255 seconds or 0, or make the stream send something more often.
  2. Bun has a per-request server.timeout(request, seconds), but BunHttpServer keeps the Bun server private (BunHttpServer.ts:433). Expose a way to call it, so a single streaming endpoint can relax the idle timeout without relaxing it for the whole server.

Scope

In scope:

  • Docs for Node and Bun.
  • The per-request timeout for Bun.

Out of scope:

  • Changing the runtimes' defaults.
  • Deno, which hasn't been checked.
  • Client timeouts. The undici client already sets no body timeout.

Open questions

  • Should StreamSse have an optional keep-alive interval that sends a comment line? It would also stop idle proxies from closing the connection.

Activity

  1. added
    documentation
    enhancement
    docker-made-me-do-it
    on Oct 21, 2026
  2. self-assigned this
    on Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

docker-made-me-do-itdocumentationenhancementplatform

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions