The idle timeout is configured via the
metadata field when creating a sandbox. The key is idle_timeout and the value is the number of seconds (as a string).Basic usage
Pass theidle_timeout key in the metadata object when creating a sandbox. The value is the idle timeout duration in seconds (as a string). When no client is connected to the sandbox for the specified duration, the sandbox will be automatically killed or paused.
How idle timeout works
The idle timeout feature monitors active connections to your sandbox:- When no connections are active — the sandbox’s end time is set to
current_time + idle_timeout_seconds. - When a connection becomes active again — the sandbox’s end time is restored to the original maximum sandbox lifetime.
- When the idle timeout elapses without any reconnection — the sandbox is killed (or paused if
autoPauseis enabled).
Sandbox.connect() or open WebSocket/HTTP connections).
Pausing instead of killing
By default, an idle sandbox is killed when the idle timeout expires. If you want the sandbox to be paused instead so you can resume it later, enable theautoPause option:
When
autoPause is enabled, the sandbox state transitions to paused on idle timeout. You can connect to it later to resume execution.Combining with other metadata
Theidle_timeout metadata key can be combined with other metadata keys you may already use:
Timeout constraints
Disabling idle timeout
To explicitly disable the idle timeout for a sandbox, simply omit theidle_timeout key from the metadata, or set it to "0":