diff --git a/docs/sandbox/auto-resume.mdx b/docs/sandbox/auto-resume.mdx index 06d04e33..b89829f6 100644 --- a/docs/sandbox/auto-resume.mdx +++ b/docs/sandbox/auto-resume.mdx @@ -54,6 +54,24 @@ sandbox = Sandbox.create( If you use `autoResume: false`, resume explicitly with [`Sandbox.connect()`](/docs/sandbox/connect). +## Timeout after auto-resume + +When a sandbox auto-resumes, it starts a **new timeout equal to the original timeout set at creation**. +The countdown begins from the moment the sandbox resumes, not from when it was first created. + +For example, if you create a sandbox with a 10-minute timeout: + +1. The sandbox runs for 10 minutes, then pauses. +2. Activity arrives and the sandbox auto-resumes. +3. A fresh 10-minute timeout starts. +4. If no further activity resets the timeout, the sandbox pauses again after 10 minutes. + +This cycle repeats every time the sandbox auto-resumes — the lifecycle configuration (`onTimeout: "pause"` + `autoResume: true`) is persistent across pause/resume cycles. + + +You can change the timeout after the sandbox resumes by calling `setTimeout`/`set_timeout`. See [Change sandbox timeout during runtime](/docs/sandbox#change-sandbox-timeout-during-runtime). + + ## What counts as activity Auto-resume is triggered by the sandbox activity - that's both HTTP traffic and controlling the sandbox from the SDK. @@ -304,5 +322,6 @@ print(result.stdout) ## Cleanup Auto-resume is persistent, meaning if your sandbox resumes and later times out again, it will pause again. +Each time the sandbox resumes, the original timeout resets — so the sandbox keeps cycling between running and paused as long as activity arrives. If you call `.kill()`, the sandbox is permanently deleted and cannot be resumed. diff --git a/docs/sandbox/persistence.mdx b/docs/sandbox/persistence.mdx index 3042df07..0a9a6c69 100644 --- a/docs/sandbox/persistence.mdx +++ b/docs/sandbox/persistence.mdx @@ -209,7 +209,7 @@ Sandbox.kill(sbx.sandbox_id) ## Sandbox's timeout -When you connect to a sandbox, the inactivity timeout resets. The default is 5 minutes, but you can pass a custom timeout to the `Sandbox.connect()` method: +When you connect to a sandbox (or it auto-resumes), the timeout resets to the value originally set at creation time. The default is 5 minutes, but you can pass a custom timeout to the `Sandbox.connect()` method: ```js JavaScript & TypeScript