Skip to content

fix(hub): stop Bun's idle timeout dropping quiet requests - #177

Merged
TheGreatAxios merged 1 commit into
mainfrom
cl-12102-stop-buns-10-second-idle-timeout-from-dropping-slow-requests
Nov 4, 2026
Merged

TheGreatAxios merged 1 commit into
mainfrom
cl-12102-stop-buns-10-second-idle-timeout-from-dropping-slow-requests

Conversation

@TheGreatAxios

Copy link
Copy Markdown
Contributor

Closes CL-12102

The live-app proxy now turns off Bun's idle timeout for each forwarded HTTP request with server.timeout(request, 0), so the person's app decides how long a response may stay quiet. WebSocket handling is unchanged. The hub's Bun.serve now sets idleTimeout: 120 instead of relying on Bun's 10-second default; the run stream's 5-second heartbeat stays well inside it.

Verified on Bun 1.4.4 with a standalone script: with the default, a response that sent nothing for 25 seconds (a slow first byte, or a stream that paused mid-response) was reset at about 12 seconds. With server.timeout(req, 0) or idleTimeout: 120 it completed. Lint, format check, typecheck, tests, pins and vendor checks pass.

@linear-code

linear-code Bot commented Nov 4, 2026

Copy link
Copy Markdown

CL-12102

@TheGreatAxios
TheGreatAxios marked this pull request as ready for review November 4, 2026 22:42
@corbits-triage

corbits-triage Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Triage: Pass

No changes needed from you. A maintainer will review this pull request.

Approve held: code review has 1 finding at P2 or above open on this head.

Comment thread apps/hub/src/server.ts
hostname: runtime.hostname,
port: runtime.port,
// Bun's 10-second default drops slow routes; the run stream's 5-second heartbeat stays well inside this.
idleTimeout: 120,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 · 120s idle timeout still drops hub routes that can stay silent for up to 300s

Bun closes a connection after idleTimeout seconds with no bytes sent. This hub serves POST /api/tenants/:t/workflows/deployments (the route agent-token-bridge.ts matches), and that route sends nothing until it has installed, probed and gated the source. Per the comment in deploy-tools.ts, those stages can take 120s + 120s + 60s, which is why callers allow DEPLOY_TIMEOUT_MS = 300_000. The web client likewise allows 5 minutes per hub call, coordinator deploys included (HUB_REQUEST_CEILING_MS). The vendored Interchange hub uses idleTimeout: 0 for the same routes. With 120, any deploy whose stages take more than about 2 minutes in total gets its socket reset, while the hub keeps working and finishes the deploy.

A workflow or coordinator deploy where sidecar ensure plus connection take more than 120s, e.g. a slow container start, so no response byte goes out within 120s.

Resolve this comment. Triage will not finish while it is open.

@TheGreatAxios
TheGreatAxios merged commit 8e0a5aa into main Nov 4, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant