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
Copy file name to clipboardExpand all lines: packages/projects-docs/pages/sdk/core-concepts.mdx
+4-6Lines changed: 4 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,7 +51,7 @@ Sandboxes have three states of persistence:
51
51
52
52
By default, when a Sandbox is hibernated, a memory snapshot is created. This allows for near-instant resumes the next time the Sandbox is accessed—typically within 0.5–2 seconds.
53
53
54
-
- Hibernated Sandboxes are stored on disk for up to 7 days.
54
+
- Hibernated Sandboxes are stored on disk for up to 7 days
55
55
- After 7 days, or if disk space is limited, Sandboxes may be archived to long-term storage.
56
56
- Archived Sandboxes are slower to resume, but still retain their full state.
57
57
@@ -60,7 +60,7 @@ By default, when a Sandbox is hibernated, a memory snapshot is created. This all
60
60
While advanced persistence controls are coming in future SDK versions, you can improve reliability and startup times today by following these best practices:
61
61
62
62
- Persist workspace data to Git or a database.
63
-
- Prefer deleting Sandboxes over hibernating when long inactivity is expected.
63
+
- Prefer deleting Sandboxes over hibernating when longer inactivity is expected.
64
64
- On resume, recreate the environment from a template and pull data from Git or your database.
65
65
66
66
These steps reduce reliance on long-term VM snapshots and improve resume consistency—especially in high-scale or collaborative environments.
@@ -69,8 +69,6 @@ These steps reduce reliance on long-term VM snapshots and improve resume consist
69
69
70
70
The Sandbox lifecycle defines how environments are created, used, paused, resumed, and eventually cleaned up. Users may interact with Sandboxes directly, or indirectly via agents (such as automation tools or connected services).
71
71
72
-
Below are the key stages of the lifecycle and how to manage them effectively:
73
-
74
72
📘 For detailed API usage, refer to [Lifecycle Management](./manage-sandboxes)
75
73
76
74
### Template creation
@@ -108,8 +106,8 @@ Below are the key stages of the lifecycle and how to manage them effectively:
108
106
- The user or agent starts a new session on a previously hibernated Sandbox.
// How quickly the sandbox should hibernate after inactivity. Set
54
-
//this field to the maximum 24 hours (See deprecation below)
55
-
hibernationTimeoutSeconds: 86400,
53
+
// How quickly the sandbox should hibernate after inactivity. Recommended
54
+
//setting is 24 hours
55
+
hibernationTimeoutSeconds: 300,
56
56
57
57
// Configure if Sandbox should wake up automatically on HTTP
58
-
// or requests or WebSocket connections. Set both of these to `false`
59
-
//(See deprecation below)
58
+
// or requests or WebSocket connections. Recommended setting
59
+
//is false
60
60
automaticWakeupConfig: {
61
-
http: false,
61
+
http: true,
62
62
websocket: false
63
63
}
64
64
})
65
65
```
66
66
67
67
<Callouttype="warning">
68
-
Both `hibernationTimeoutSeconds` and `wakeupConfig`have been deprecated. Manual lifecycle management is required to scale, control costs, and create a predictable user experience. These features will not be available in the next major version.
68
+
Both `hibernationTimeoutSeconds` and `wakeupConfig`should be carefully evaluated. Manual lifecycle management is considered best practice and is required to scale, control costs, and create a predictable user experience.
69
69
</Callout>
70
70
71
71
Each Sandbox has the following properties, with information about its own instance:
Ensure the parent Sandbox is in a `HIBERNATED` state before performing this operation.
89
-
90
88
<Callouttype="warning">
91
-
Depending on the state of the parent Sandbox:
89
+
Be careful with the state of the parent Sandbox:
92
90
93
-
-**RUNNING**: This creates what we call a "Live Fork", which is limited to 5. The created Sandboxes will share memory with the parent and can cause a degraded experience
94
-
-**ARCHIVED**: The parent Sandbox first needs to be resumed, which can take 10-60 seconds, causing the creation to take a long time
91
+
-**HIBERNATED**: It will be a fast fork of 1-3 seconds
92
+
-**RUNNING**: This creates what we call a "Live Fork", which is limited to 5. The created Sandboxes will share memory with the parent and causes a degraded experience if excessively used
93
+
-**ARCHIVED**: The parent Sandbox first needs to be resumed, which can take 20-60 seconds, causing the creation to take a long time
95
94
96
95
</Callout>
97
96
@@ -105,12 +104,10 @@ There is also a `/project/sandbox` folder, but consider this deprecated. Use `/p
105
104
106
105
The primary persistence mechanism is based on git with a local remote. This means the workspace is initialized with git automatically.
107
106
108
-
<Callouttype="warning">
109
-
Running git commands in the workspace without setting a new remote will cause issues with persistence.
110
-
</Callout>
111
-
112
107
### Using git in the root workspace
113
108
109
+
Since the default persistence of a Sandbox is using git you should not run any git commands in the workspace unless you change the remote.
110
+
114
111
```bash
115
112
# Remove the default local remote and add your own
Copy file name to clipboardExpand all lines: packages/projects-docs/pages/sdk/hibernate.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ import { Callout } from 'nextra-theme-docs'
7
7
8
8
# Hibernate Sandboxes
9
9
10
-
Hibernating a Sandbox allows you to stop its running costs and resume it at a later point. When hibernating the Sandbox it will produce a snapshot with memory and disk, but depending on health cluster and days passed change its state.
10
+
Hibernating a Sandbox allows you to stop its running costs and resume it at a later point. When hibernating the Sandbox it will produce a snapshot with memory and disk, but depending on cluster load, and days passed, the persistence will change its state.
Copy file name to clipboardExpand all lines: packages/projects-docs/pages/sdk/index.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ CodeSandbox SDK enables you to quickly create and run isolated sandboxes securel
15
15
The SDK can be used to run concurrent VMs to support multiple use cases such as browser editors, AI agents, code interpretation and more.
16
16
17
17
<Callout>
18
-
We are soon to introduce **long term persistence**. Please read our [RFC](https://gist.github.com/christianalfoni/70335f989312484c8f348148aa2e166e) for planned deprecations and future roadmap.
18
+
We are currently working on improvements to our infrastructure. Please read our [RFC](https://gist.github.com/christianalfoni/70335f989312484c8f348148aa2e166e) for planned deprecations and future roadmap. We would love your feedback!
Copy file name to clipboardExpand all lines: packages/projects-docs/pages/sdk/manage-sandboxes.mdx
+6-2Lines changed: 6 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,12 +9,16 @@ import { Callout } from 'nextra-theme-docs'
9
9
10
10
Use your own persistence layer to track VM sessions and sandbox lifecycle states. This will give you the following benefits:
11
11
12
-
- A request does not accidentally extend hibernation timeout
12
+
- A request does not accidentally keep a Sandbox running
13
13
- A webhook can be called from a process inside the Sandbox to control lifecycle
14
14
- As hibernation is directly called, error management is straight forward
15
15
- No **ux** vs **cost** tradeoff
16
16
- Latency is reduced as session/db state determines state of Sandbox, preventing unecessary calls to `resume`
17
17
18
+
<Callout>
19
+
To adopt best practices set `hibernationTimeoutSeconds` to `86400` (24 hours) and `automaticWakeupConfig` to `false` when you create Sandboxes.
20
+
</Callout>
21
+
18
22
How you manage the resume/hibernate/delete part of the lifecycle depends on your use case. You might have user sessions, agent sessions or maybe sessions bound to accessing a process exposing a host. Regardless you want to `resume` the Sandbox when the session starts and `hibernate` or `delete` when the sessions ends.
19
23
20
24
Examples of identifying lifecycles:
@@ -126,7 +130,7 @@ setInterval(async () => {
126
130
127
131
## Managed persistence example
128
132
129
-
You can choose not to rely on our persistence at all. By using `delete` instead of `hibernate`, you minimize costs and maintain optimal control of Sandbox resumes.
133
+
You can choose not to rely on our persistence at all. By using `delete`, instead of `hibernate`, you maintain optimal control of Sandbox resumes.
130
134
131
135
When you want to stop using the Sandbox, push any changes to your database or Git. Then `delete` the Sandbox. When you want to resume, `create` a new Sandbox from the template and pull data back from your database or Git.
0 commit comments