11---
2- title : " Control sandbox lifetime "
3- description : " Learn how to control how long your sandbox stays alive using the lifetime option."
4- url : /examples/sandboxes_lifetime_control /
2+ title : " Control sandbox timeout "
3+ description : " Learn how to control how long your sandbox stays alive using the timeout option."
4+ url : /examples/sandboxes_timeout_control /
55layout : sandbox-example.tsx
66---
77
8- You can control how long your sandbox stays alive using the lifetime option:
8+ You can control how long your sandbox stays alive using the timeout option:
99
1010``` ts
1111import { Sandbox } from " @deno/sandbox" ;
1212
1313// Default: "session" - sandbox shuts down when you close/dispose the client
14- await using sandbox = await Sandbox .create ({ lifetime : " session" });
14+ await using sandbox = await Sandbox .create ({ timeout : " session" });
1515```
1616
1717Supported duration suffixes: ` s ` (seconds), ` m ` (minutes).
@@ -23,7 +23,7 @@ import { Sandbox } from "@deno/sandbox";
2323
2424// Duration-based: keep sandbox alive for a specific time period
2525// Useful when you want the sandbox to persist after the script exits
26- const sandbox = await Sandbox .create ({ lifetime : " 5m" }); // 5 minutes
26+ const sandbox = await Sandbox .create ({ timeout : " 5m" }); // 5 minutes
2727const id = sandbox .id ;
2828// Close the *connection* to the sandbox; the sandbox keeps running
2929await sandbox .close ();
@@ -32,10 +32,10 @@ await sandbox.close();
3232const reconnected = await Sandbox .connect ({ id });
3333await reconnected .sh ` echo 'Still alive!' ` ;
3434
35- // You can still forcibly terminate it before its lifetime expires
35+ // You can still forcibly terminate it before its timeout elapses
3636await reconnected .kill ();
3737// At this point, the sandbox is no longer reconnectable
3838```
3939
40- > Need other lifetime modes? Contact
40+ > Need other timeout modes? Contact
4141> <a href =" mailto:deploy@deno.com " >deploy@deno.com </a >.
0 commit comments