Conversation
The fork endpoint has no v2 route, so an omitted timeout falls back to its own 15-second default instead of the 300 seconds create and connect get from /v2. Send the documented 5 minutes when the caller omits one. Co-authored-by: Rauf Guliyev <rguliyev@users.noreply.github.com>
🦋 Changeset detectedLatest commit: 37eca00 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
TASTE.md review: no violations found in the changed lines.
Checked: T-1 (JS / sync Python / async Python parity — all three fork paths apply the same default), T-44 (timeoutMs ms vs timeout seconds kept), T-47 (default comes from the named constants DEFAULT_SANDBOX_TIMEOUT_MS / SandboxBase.default_sandbox_timeout, no magic numbers, documented via @default and :param timeout: defaults), T-46 (signal still threaded through config.getSignal), T-36 (default is sent once on creation; no background renewal), T-69/T-70/T-71 (docstrings updated on all six fork overload/variant entries).
Not flagged as it predates this PR: the Python fork(sandbox_id, timeout=None, count=None, ...) signature has timeout/count as defaulted positionals rather than keyword-only (T-3a); per T-3a that is a next-major change, not something to fix here.
Package ArtifactsBuilt from b95bba3. Download artifacts from this workflow run. JS SDK ( npm install ./e2b-2.51.1-cursor-fix-fork-default-timeout-b339.0.tgzCLI ( npm install ./e2b-cli-2.20.1-cursor-fix-fork-default-timeout-b339.0.tgzCode Interpreter JS SDK ( npm install ./e2b-code-interpreter-2.8.1-cursor-fix-fork-default-timeout-b339.0.tgzDesktop JS SDK ( npm install ./e2b-desktop-2.4.1-cursor-fix-fork-default-timeout-b339.0.tgzPython SDK ( pip install ./e2b-2.51.0+cursor.fix.fork.default.timeout.b339-py3-none-any.whlCode Interpreter Python SDK ( pip install ./e2b_code_interpreter-2.10.0+cursor.fix.fork.default.timeout.b339-py3-none-any.whlDesktop Python SDK ( pip install ./e2b_desktop-2.6.0+cursor.fix.fork.default.timeout.b339-py3-none-any.whl |
Summary
Since 2.51.0,
Sandbox.fork()/fork()called without an explicit timeout produces sandboxes that expire about 15 seconds after they start instead of the documented 5 minutes.#1749 removed the SDK-side 5-minute default so that the API default would apply. That reasoning holds for create and connect, which moved to the v2 routes in the same PR (
NewSandboxV2.timeoutandConnectSandboxV2.timeoutboth declaredefault: 300, and/v2/sandboxes/{id}/connectdocuments it in prose). Fork was not moved:POST /sandboxes/{sandboxID}/forkstill takesSandboxForkRequest, whosetimeoutcarries the legacydefault: 15inherited from v1NewSandbox.So every fork created without
timeoutMs/timeoutreaches its timeout almost immediately. Where the sandbox lifecycle is configured withonTimeout: 'pause', that presents as forks pausing seconds after they are created; otherwise they are killed.This restores the documented 5-minute default on the fork path only — create, connect and pause keep deferring to the API — with a comment tying it to the missing v2 fork route so it can be dropped once the API's fork default matches. An explicit timeout is still sent unchanged.
Usage
Tests
packages/js-sdk/tests/sandbox/apiDefaults.test.tsandpackages/python-sdk/tests/shared/sandbox/test_api_defaults.pypinned the regression (assertingtimeoutwas absent from the fork body); they now assert the request carriestimeout: 300when the caller omits one, and still assert the explicit value is passed through.countis still omitted when unset — the fork endpoint'scountdefault is1, which is correct.Verified with
pnpm run format,pnpm run lint,pnpm run typecheck, the mocked JS suites (apiDefaults,lifecycleRequest,onResumeRequest,client) andpytest tests/shared. The live fork integration suites need a real API and were not run here.Slack Thread