You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
merge: Resolve conflict with upstream AutoResume changes
Integrate new 'What counts as activity' section from main while
preserving streamlined structure from this branch. Added prose
before the SDK example code block per documentation standards.
"auto_resume": True, # resume when traffic arrives
34
+
"auto_resume": True, # resume when activity arrives
35
35
},
36
36
)
37
37
```
@@ -51,6 +51,61 @@ AutoResume is persistent — if a sandbox resumes and later times out again, it
51
51
52
52
If `autoResume` is `false`, you can still resume a paused sandbox manually with [`Sandbox.connect()`](/docs/sandbox/connect).
53
53
54
+
## What counts as activity
55
+
56
+
Auto-resume is triggered by sandbox activity — both HTTP traffic and SDK operations.
57
+
58
+
That includes:
59
+
-`sandbox.commands.run(...)`
60
+
-`sandbox.files.read(...)`
61
+
-`sandbox.files.write(...)`
62
+
- Opening a tunneled app URL or sending requests to a service running inside the sandbox
63
+
64
+
If a sandbox is paused and `autoResume` is enabled, the next supported operation resumes it automatically. You do not need to call [`Sandbox.connect()`](/docs/sandbox/connect) first.
65
+
66
+
### SDK example: pause, then read a file
67
+
68
+
The following example writes a file, pauses the sandbox, then reads the file back. The read operation triggers an automatic resume.
69
+
70
+
<CodeGroup>
71
+
```js JavaScript & TypeScript
72
+
import { Sandbox } from'e2b'
73
+
74
+
constsandbox=awaitSandbox.create({
75
+
timeoutMs:10*60*1000,
76
+
lifecycle: {
77
+
onTimeout:'pause',
78
+
autoResume:true,
79
+
},
80
+
})
81
+
82
+
awaitsandbox.files.write('/home/user/hello.txt', 'hello from a paused sandbox')
print(f"State after read: {sandbox.get_info().state}")
106
+
```
107
+
</CodeGroup>
108
+
54
109
## Example: Web server with AutoResume
55
110
56
111
AutoResume is especially useful for web servers and preview environments. When an HTTP request arrives at a paused sandbox, the sandbox wakes up automatically to handle it.
0 commit comments