Skip to content

Commit 3569933

Browse files
committed
feat: inactivity timeout
1 parent 6e7f679 commit 3569933

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

content/docs/overview/sessions-api/quickstart.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ const session = await client.sessions.create({
9999
useProxy: true, // Use Steel's residential proxy network
100100
solveCaptcha: true, // Enable automatic CAPTCHA solving
101101
timeout: 1800000, // Set 30-minute timeout (default is 5 minutes)
102+
inactivityTimeout: 300000, // Release after 5 minutes of inactivity
102103
userAgent: 'custom-ua' // Set a custom user agent
103104
});
104105
```

content/docs/overview/sessions-api/session-lifecycle.mdx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,43 @@ session = client.sessions.create(
5454

5555
**Note:** Currently, Steel doesn’t support editing the timeout duration of a live session.
5656

57+
### Inactivity Timeout
58+
59+
By default a session runs until its `timeout` elapses, even when nothing is driving the browser. Set `inactivityTimeout` to release the session early once it stops seeing activity—any CDP command or remote input—so you don’t keep paying for an idle browser while waiting on an external step.
60+
61+
<CodeTabs storage="languageSwitcher">
62+
63+
```typescript !! Typescript -wcn
64+
import Steel from 'steel-sdk';
65+
66+
const client = new Steel();
67+
68+
// Release the session after 1 minute with no CDP or input activity,
69+
// capped at a 10-minute hard limit.
70+
const session = await client.sessions.create({
71+
timeout: 600000, // 10 minutes (hard cap)
72+
inactivityTimeout: 60000, // release after 1 minute of inactivity
73+
});
74+
```
75+
76+
77+
```python !! Python -wcn
78+
import os
79+
from steel import Steel
80+
81+
client = Steel()
82+
83+
# Release the session after 1 minute with no CDP or input activity,
84+
# capped at a 10-minute hard limit.
85+
session = client.sessions.create(
86+
api_timeout=600000, # 10 minutes (hard cap)
87+
inactivity_timeout=60000, # release after 1 minute of inactivity
88+
)
89+
```
90+
</CodeTabs>
91+
92+
**Note:** `timeout` is always the hard cap on a session’s lifetime. If `inactivityTimeout` is greater than or equal to `timeout` it has no effect—`timeout` elapses first. Omit `inactivityTimeout` to disable inactivity-based release (the default).
93+
5794
### **Releasing a Session**
5895

5996
When you're done with a session, it's best practice to release it explicitly rather than waiting for the timeout. You can release a session any time before the timeout is up by calling the `release` method.

0 commit comments

Comments
 (0)