Skip to main content
Kernel browsers should be terminated after you’re done with them.
Using Playwright/Puppeteer’s method browser.close() does not delete the browser. Use one of the methods below to delete the browser.

Deleting a browser via session ID

Every browser instance has a session_id. You can delete any browser using its session ID:
import Kernel from '@onkernel/sdk';

const kernel = new Kernel();

await kernel.browsers.deleteByID('htzv5orfit78e1m2biiifpbv');

Automatic deletion via timeout

If you don’t manually delete a browser, it will be automatically deleted after a configurable timeout (default 60 seconds). The timeout begins when the browser does not see a CDP or live view connection. You can set a custom timeout of up to 72 hours when creating a browser:
import Kernel from '@onkernel/sdk';

const kernel = new Kernel();

const browser = await kernel.browsers.create({ timeout_seconds: 300 });
console.log(browser.session_id);