keep_alive
Keep the session when your client disconnects (dedicated threads only).
Use it for: Agents and step-by-step workflows that disconnect between steps, and code that may lose its connection, without losing the logged-in browser.
Browsers: Google Chrome, Microsoft Edge, Brave, Opera, Naver Whale, Yandex Browser, Chromium, Patchright, Camoufox, Firefox, WebKit.
Details
- Type:
boolean - Default: false
- Example:
{"keep_alive":true}
A disconnect no longer ends the session: reconnect to the same wsUrl or cdpUrl until inactivity_timeout runs out. Over wsUrl: on the first connect create your context and page as usual (browser.newContext(), newPage()); after a reconnect, browser.contexts() lists the contexts you created, with their pages, cookies and page state intact. Over cdpUrl (connectOverCDP): work in the browser's default context, browser.contexts()[0] — contexts created with newContext() over CDP close when the client disconnects.
Not on Rebrowser. Dedicated threads only (403 keep_alive_requires_dedicated on shared plans). The session is billed while it's alive, attached or not — and browser.close() only disconnects: the session ends after inactivity_timeout without a client, or at once with DELETE /v1/me/threads/{sessionId} (or End in the dashboard). Set inactivity_timeout to how long it may wait for you.
Used in
- Case 78: keep_alive: an agent run that survives its client going away
- Chrome you can disconnect from and come back to
- Microsoft Edge over CDP that survives a disconnect
- Headful Opera over CDP that survives a disconnect
All options: launch options.