Skip to content

Commit 128f295

Browse files
adjustments
1 parent c67970f commit 128f295

File tree

5 files changed

+25
-26
lines changed

5 files changed

+25
-26
lines changed

packages/projects-docs/pages/sdk/core-concepts.mdx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Sandboxes have three states of persistence:
5151

5252
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.
5353

54-
- Hibernated Sandboxes are stored on disk for up to 7 days.
54+
- Hibernated Sandboxes are stored on disk for up to 7 days
5555
- After 7 days, or if disk space is limited, Sandboxes may be archived to long-term storage.
5656
- Archived Sandboxes are slower to resume, but still retain their full state.
5757

@@ -60,7 +60,7 @@ By default, when a Sandbox is hibernated, a memory snapshot is created. This all
6060
While advanced persistence controls are coming in future SDK versions, you can improve reliability and startup times today by following these best practices:
6161

6262
- 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.
6464
- On resume, recreate the environment from a template and pull data from Git or your database.
6565

6666
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
6969

7070
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).
7171

72-
Below are the key stages of the lifecycle and how to manage them effectively:
73-
7472
📘 For detailed API usage, refer to [Lifecycle Management](./manage-sandboxes)
7573

7674
### Template creation
@@ -108,8 +106,8 @@ Below are the key stages of the lifecycle and how to manage them effectively:
108106
- The user or agent starts a new session on a previously hibernated Sandbox.
109107
- The Sandbox resumes using the SDK.
110108
- Resume times vary based on persistence:
111-
- From memory: 0.5–2 seconds
112-
- From disk: 5–20 seconds
109+
- From memory/disk snapshot: 0.5–2 seconds
110+
- From disk snapshot: 5–20 seconds
113111
- From archive: 20–60 seconds
114112

115113
### Deleting

packages/projects-docs/pages/sdk/create.mdx

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,22 @@ const sandbox = await sdk.sandboxes.create({
5050
// What VM Tier to use for the Sandbox
5151
vmTier: VMTier.Micro,
5252

53-
// 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,
5656

5757
// 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
6060
automaticWakeupConfig: {
61-
http: false,
61+
http: true,
6262
websocket: false
6363
}
6464
})
6565
```
6666

6767
<Callout type="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.
6969
</Callout>
7070

7171
Each Sandbox has the following properties, with information about its own instance:
@@ -85,13 +85,12 @@ const sandbox = await sdk.sandboxes.create({
8585
})
8686
```
8787

88-
Ensure the parent Sandbox is in a `HIBERNATED` state before performing this operation.
89-
9088
<Callout type="warning">
91-
Depending on the state of the parent Sandbox:
89+
Be careful with the state of the parent Sandbox:
9290

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
9594

9695
</Callout>
9796

@@ -105,12 +104,10 @@ There is also a `/project/sandbox` folder, but consider this deprecated. Use `/p
105104

106105
The primary persistence mechanism is based on git with a local remote. This means the workspace is initialized with git automatically.
107106

108-
<Callout type="warning">
109-
Running git commands in the workspace without setting a new remote will cause issues with persistence.
110-
</Callout>
111-
112107
### Using git in the root workspace
113108

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+
114111
```bash
115112
# Remove the default local remote and add your own
116113
git remote remove origin

packages/projects-docs/pages/sdk/hibernate.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Callout } from 'nextra-theme-docs'
77

88
# Hibernate Sandboxes
99

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.
1111

1212
| **State** | **Resume Time** | **Description** |
1313
| ----------- | --------------- | ------------------------------------------------- |

packages/projects-docs/pages/sdk/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ CodeSandbox SDK enables you to quickly create and run isolated sandboxes securel
1515
The SDK can be used to run concurrent VMs to support multiple use cases such as browser editors, AI agents, code interpretation and more.
1616

1717
<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!
1919
</Callout>
2020

2121
## Quickstart

packages/projects-docs/pages/sdk/manage-sandboxes.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@ import { Callout } from 'nextra-theme-docs'
99

1010
Use your own persistence layer to track VM sessions and sandbox lifecycle states. This will give you the following benefits:
1111

12-
- A request does not accidentally extend hibernation timeout
12+
- A request does not accidentally keep a Sandbox running
1313
- A webhook can be called from a process inside the Sandbox to control lifecycle
1414
- As hibernation is directly called, error management is straight forward
1515
- No **ux** vs **cost** tradeoff
1616
- Latency is reduced as session/db state determines state of Sandbox, preventing unecessary calls to `resume`
1717

18+
<Callout>
19+
To adopt best practices set `hibernationTimeoutSeconds` to `86400` (24 hours) and `automaticWakeupConfig` to `false` when you create Sandboxes.
20+
</Callout>
21+
1822
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.
1923

2024
Examples of identifying lifecycles:
@@ -126,7 +130,7 @@ setInterval(async () => {
126130

127131
## Managed persistence example
128132

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.
130134

131135
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.
132136

0 commit comments

Comments
 (0)