Skip to content

fix(vercel-sandbox): disable headers timeout on default agent#172

Open
umairnadeem wants to merge 1 commit intovercel:mainfrom
umairnadeem:fix/disable-headers-timeout
Open

fix(vercel-sandbox): disable headers timeout on default agent#172
umairnadeem wants to merge 1 commit intovercel:mainfrom
umairnadeem:fix/disable-headers-timeout

Conversation

@umairnadeem
Copy link
Copy Markdown

Problem

DEFAULT_AGENT in base-client.ts disables bodyTimeout but leaves undici's headersTimeout at its 5-min default:

const DEFAULT_AGENT = new Agent({
  bodyTimeout: 0, // disable body timeout to allow long logs streaming
});

That breaks cmd.wait(). It issues a single GET to /v1/sandboxes/{id}/cmd/{cmdId}?wait=true — the API holds the connection open and only sends response headers once the command finishes. If the underlying command takes longer than 5 min, undici aborts the request before headers arrive and throws TimeoutError (code: 23), even though the sandbox itself is still happily running.

Repro

Hit this via @remotion/vercel's createSandbox. Set Sandbox.create({ timeout: 15 * 60 * 1000 }). Sandbox lived its full 15 min per the Vercel dashboard. Script died at exactly 5 min with TimeoutError: The operation timed out. mid-pnpm install. So the timeout option is effectively capped at 5 min for any command (cold pnpm install, browser download, etc.) that runs longer.

Fix

Also set headersTimeout: 0 on DEFAULT_AGENT. Matches the existing intent — the comment on bodyTimeout: 0 says "disable body timeout to allow long logs streaming", and the long-poll endpoint is just as much a long-running pattern as streaming logs.

No public API change.

`DEFAULT_AGENT` already disables `bodyTimeout` to support long-running
streams, but undici's `headersTimeout` was left at its 5-min default.
That cuts off `cmd.wait()`'s long-poll request when a sandbox command
runs longer than 5 minutes, even when the sandbox itself has a longer
timeout. Set `headersTimeout: 0` to match the existing intent.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 1, 2026

@umairnadeem is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

@umairnadeem
Copy link
Copy Markdown
Author

cc @QuiiBz

umairnadeem added a commit to openslop/openslop that referenced this pull request May 1, 2026
`@vercel/sandbox`'s default undici Agent disables `bodyTimeout` but leaves
`headersTimeout` at undici's 5-min default, causing `cmd.wait()`'s long-poll
to abort after 5 min even when the sandbox itself has a longer timeout. That
was capping `createSandbox`'s `timeoutInMilliseconds: 15 * 60 * 1000` at 5 min
and breaking long `pnpm install` steps inside `create-snapshot.ts`.

Patches both the ESM and CJS dist files via patch-package. Reapplied on
postinstall, including in the Vercel build container. Locked to the version
in package-lock.json (1.10.0); patch will be removed once vercel/sandbox#172
ships in a release.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Member

@QuiiBz QuiiBz left a comment

Choose a reason for hiding this comment

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

Thanks! We require verified commit signatures to merge in this repositories, could you update your commit to sign it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants