You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 4550c4f
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: browsers/playwright-execution.mdx
+202-1Lines changed: 202 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,7 @@ When you execute Playwright code through this API:
14
14
- You have access to `page`, `context`, `browser`, and browser-wide `webmcp` helpers
15
15
- You can `return` a value, which is returned in the response
16
16
- Execution is isolated in a fresh context each time
17
+
- Every call runs in an [executor](#executors). Calls without `executor` share the default executor and the active tab; named executors each own a tab and run concurrently with each other
Every call runs in an executor: a dedicated Node.js process in the browser's VM with its own connection to Chromium. Calls on the same executor run one at a time, in the order they arrive. Calls on different executors run concurrently, and a timeout, crash, or blocked event loop in one executor doesn't affect the others.
230
+
231
+
Use named executors to drive several tabs of one browser in parallel. Give each independent task its own executor name, and reuse a name for the sequential steps of one task.
232
+
233
+
### The default executor
234
+
235
+
Calls without `executor` run in the executor named `default`, which always exists. Passing `executor: "default"` is the same as omitting it. In the default executor, `page` is bound to an active tab reported by Chrome (the foreground tab in single-window sessions). Use `browser.contexts()` to select a context or page explicitly.
236
+
237
+
### Named executors
238
+
239
+
Pass any other name (`^[A-Za-z0-9_-]{1,64}$`) to run the call in a named executor. The first call with a new name creates it. Each named executor owns a tab: its first call opens a new background tab in the default browser context, and `page` is bound to that tab on every later call while it stays open. Opening it doesn't change the active tab of an existing window. If the tab is closed, the next call opens a new one.
240
+
241
+
Ownership only decides what `page` is bound to. Executor code can still reach other tabs through `context` and `browser`.
242
+
243
+
The response includes a `tab` object with the tab `page` was bound to:
`created` is `true` when this call opened the tab. `tab` is absent if the call failed before binding a tab.
254
+
255
+
### Run tasks in parallel
256
+
257
+
This example runs two tasks at the same time in two named executors, reuses one of them, then lists and deletes an executor. It uses an existing session and client, as in the examples above.
A browser can have at most **8 named executors**; the default executor doesn't count. A call that would create a ninth returns `409` with a `message` and an `executors` array listing the current executors, so you can delete one and retry.
410
+
411
+
Named executors aren't removed automatically while the browser runs. They're removed and their tabs closed when the browser shuts down. Delete executors you're done with so long-lived browsers don't hit the limit.
412
+
413
+
A call with `executor` to a browser whose image predates executors fails with `400`. Calls without `executor` work on every image.
414
+
415
+
### List and delete executors
416
+
417
+
`GET /browsers/{id_or_name}/playwright/executors` returns the browser's executors, default first. Each entry has `name`, `busy` (whether a call is currently running on the executor), `created_at`, and `last_used_at`; named executors with an open tab also report `target_id` and `url`.
418
+
419
+
`DELETE /browsers/{id_or_name}/playwright/executors/{name}` stops the executor's process and returns `204`. It closes the executor's tab unless you pass `close_tab=false`. A call running on the executor fails with an error saying the executor was deleted, and the name can be reused afterwards. Unknown names return `404`.
420
+
421
+
Deleting `default` restarts it instead of removing it: its process is stopped, and queued and later calls run on a new process. It owns no tab, so `close_tab` has no effect. Use this to recover the default executor from a stuck state.
422
+
423
+
### Timeouts and crashes
424
+
425
+
After a timeout, the executor keeps its process but drops its browser connection, so code abandoned by the timeout can't keep driving the browser. After a crash or a blocked event loop, the next call on that executor starts a fresh process. Either way, other executors keep running.
426
+
226
427
## Timeout configuration
227
428
228
429
Set `timeout_sec` for the work each request performs. The API defaults to 60 seconds and allows up to 300 seconds, but most short scripts don't need that budget. Start with:
Copy file name to clipboardExpand all lines: browsers/profiles/concurrency.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ A browser loads profile data as a snapshot. Saving replaces the profile's comple
10
10
11
11
For a personal assistant or another workflow where concurrent tasks act as the same end user, start one browser with that user's profile and open multiple tabs in it. Tabs in the same browser context share a live cookie jar and persistent origin storage, so a login or cookie update in one tab is available to the others without loading the profile again or restarting Chrome. Tab-local state such as `sessionStorage` remains separate.
12
12
13
-
Open additional tabs with Playwright's `context.newPage()`. Keep each task on its own `Page`, and coordinate actions that change shared account or browser state. See [Playwright Execution](/browsers/playwright-execution) for ways to run code against the browser.
13
+
Give each task its own named [Playwright executor](/browsers/playwright-execution#executors). Each executor owns a tab and runs concurrently with the others, so `page` in a task's calls is always that task's tab. Coordinate actions that change shared account or browser state. See [Playwright Execution](/browsers/playwright-execution) for ways to run code against the browser.
14
14
15
15
<Tip>
16
16
Headful, non-GPU browsers use `8GiB` by default. For tab-heavy workloads, set `memory` to `16GiB` when you [create the browser](/api-reference/browsers/create-a-browser-session).
Copy file name to clipboardExpand all lines: browsers/repl.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -359,7 +359,7 @@ The API process directly owns one lazily started Node child and is its sole supe
359
359
| Execution timeout | Child process group destroyed | Replaced on next request |
360
360
| Crash, OOM, uncaught asynchronous exception, or protocol corruption | Child process group destroyed | Replaced on next request |
361
361
362
-
Timeouts are destructive because abandoned JavaScript cannot safely coexist with a later cell. Check `response.repl_terminated` to see whether your own request destroyed the REPL it ran in — the next call starts a fresh one and earlier top-level bindings are gone. Calls are serialized, so executions on the same browser cannot interleave.
362
+
Timeouts are destructive because abandoned JavaScript cannot safely coexist with a later cell. Check `response.repl_terminated` to see whether your own request destroyed the REPL it ran in — the next call starts a fresh one and earlier top-level bindings are gone. Calls are serialized, so executions on the same browser cannot interleave. To run Playwright tasks in parallel across tabs of one browser, use named [executors](/browsers/playwright-execution#executors) with Playwright execution.
Copy file name to clipboardExpand all lines: changelog.mdx
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,16 @@ import { YouTubeVideo } from '/snippets/youtube-video.mdx';
9
9
For API library updates, see the [Node SDK](https://github.com/onkernel/kernel-node-sdk/blob/main/CHANGELOG.md), [Python SDK](https://github.com/onkernel/kernel-python-sdk/blob/next/CHANGELOG.md), and [Go SDK](https://github.com/onkernel/kernel-go-sdk/blob/main/CHANGELOG.md) changelogs.
- Added **named [Playwright executors](/browsers/playwright-execution#executors)**. Pass `executor` to `playwright.execute` to run the call in a dedicated process that owns its own tab. Calls on different executors run concurrently and fail independently; calls on the same executor run one at a time. Calls without `executor` keep running in the `default` executor on the active tab. The response now includes the `tab` the call was bound to, a browser can have up to 8 named executors, and new endpoints list and delete them. Available in the Node, Python, and Go SDKs from 0.120.0.
16
+
17
+
## Documentation updates
18
+
19
+
- Documented [executors](/browsers/playwright-execution#executors) in the Playwright execution guide, with a multi-language example that runs two tasks in parallel in one browser. Updated the [profile concurrency](/browsers/profiles/concurrency) and [Browser REPL](/browsers/repl) pages to point at named executors for parallel work across tabs.
0 commit comments