Skip to main content

Overview

By default, Browserbase sessions have a timeout period after which they automatically terminate. You can extend this duration either project-wide or per-session. This is useful for long-running tasks, complex workflows, or any scenario where you need more time than the default allows.
The maximum session duration is 6 hours. Once a session times out, it cannot be reused.

Project-Wide Timeout Settings

You can change the default session timeout for all sessions in your project through the dashboard settings.

Custom Session Timeout

For more control, set a custom timeout when creating individual sessions. This overrides the project default.
import Browserbase from "browserbase";

const bb = new Browserbase({
  apiKey: process.env.BROWSERBASE_API_KEY!,
});

// Creates a session with a timeout of 3600 seconds (1 hour)
const session = await bb.sessions.create({
  projectId: process.env.BROWSERBASE_PROJECT_ID!,
  timeout: 3600,
});

Timeouts vs Keep Alive

Setting a custom timeout extends how long a session can run, but the session will still terminate when you disconnect. If you need to disconnect and reconnect to the same session, use Keep Alive instead. For sessions that need both extended duration and reconnection support, configure both options:
const session = await bb.sessions.create({
  projectId: process.env.BROWSERBASE_PROJECT_ID!,
  keepAlive: true,
  timeout: 3600, // 1 hour
});

Keep Alive

Learn how to keep sessions alive across disconnects.