barebrowse 0.5.3 → 0.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,68 @@
1
+ # Design: Harden assess tool
2
+
3
+ ## Architecture
4
+
5
+ ### Current flow (broken)
6
+ ```
7
+ assess(url) → connect({ mode: 'hybrid' }) ← NEW browser, no cookies
8
+ → assessFn(page, url)
9
+ → page.close() ← kills browser
10
+ ```
11
+
12
+ ### New flow
13
+ ```
14
+ assess(url) → getPage() ← reuse session browser
15
+ → page.createTab() ← new tab in same browser
16
+ → tab.injectCookies(url) ← cookie injection
17
+ → assessFn(tab, url) ← assess uses tab
18
+ → tab.close() ← close tab only
19
+ timeout guard wraps entire flow
20
+ retry wraps entire flow
21
+ ```
22
+
23
+ ## Key design decisions
24
+
25
+ ### Why a new tab, not the session page?
26
+ wearehere's `assess()` calls:
27
+ - `session.send('Page.addScriptToEvaluateOnNewDocument', ...)` — injects fingerprint detection scripts
28
+ - `networkSession.on('Network.requestWillBeSent', ...)` — monitors all network traffic
29
+
30
+ These would pollute the session page. A separate tab has its own CDP session with isolated Page/Network domains.
31
+
32
+ ### createTab() page-like interface
33
+ wearehere expects a page object with: `goto()`, `cdp` (raw session), `waitForNetworkIdle()`. createTab() returns exactly this interface:
34
+
35
+ ```javascript
36
+ {
37
+ goto(url, timeout) // navigate tab
38
+ cdp // raw CDP session for this tab
39
+ waitForNetworkIdle(opts) // reuses existing waitForNetworkIdle()
40
+ injectCookies(url) // cookie injection for this tab
41
+ close() // close tab, NOT the browser
42
+ }
43
+ ```
44
+
45
+ ### Retry strategy
46
+ ```
47
+ attempt 1: assess with 45s timeout
48
+ fail → wait 2s
49
+ attempt 2: assess with 45s timeout (if browser crashed, reset _page first)
50
+ fail → return { error: "assessment_failed", ... }
51
+ ```
52
+
53
+ ### Timeout implementation
54
+ ```javascript
55
+ const result = await Promise.race([
56
+ doAssess(page, url, opts),
57
+ new Promise((_, reject) => setTimeout(() => reject(new Error('timeout')), 45000))
58
+ ]);
59
+ ```
60
+ On timeout, the tab is closed in a finally block.
61
+
62
+ ## Files changed
63
+ | File | Change |
64
+ |------|--------|
65
+ | `src/index.js` | Add `createTab()` and tab's `close()` to connect() return object |
66
+ | `mcp-server.js` | Rewrite assess case: use getPage().createTab(), add retry + timeout |
67
+ | `README.md` | Update assess description, add self-healing mention |
68
+ | `barebrowse.context.md` | Update assess section, document createTab() |
@@ -0,0 +1,71 @@
1
+ # Plan: Harden assess tool — session reuse + self-healing
2
+
3
+ ## Plan ID
4
+ `harden-assess`
5
+
6
+ ## Summary
7
+ Make the assess tool reuse the MCP session's browser instance (cookies, headed fallback) instead of spawning throwaway browsers, add retry logic for transient failures, and add a timeout guard so no single assessment can hang forever.
8
+
9
+ ## Problem Statement
10
+ The `assess` tool in `mcp-server.js` calls `connect({ mode: 'hybrid' })` directly — creating a fresh headless browser per call with no cookies, no session state, and no headed fallback. Every other MCP tool uses the `getPage()` singleton. This causes:
11
+
12
+ 1. **No cookies** — assess browses as a stranger, getting blocked by consent walls and bot detection that cookies would bypass
13
+ 2. **No headed fallback reuse** — if the singleton already fell back to headed mode, assess still starts fresh headless and hits the same blocks
14
+ 3. **No retry** — any failure (browser crash, navigation timeout, CDP disconnect) kills the assessment with no recovery
15
+ 4. **No timeout guard** — if `wearehere`'s `assess()` hangs (e.g. network idle never resolves), the MCP call blocks indefinitely
16
+
17
+ However, assess can't simply use the shared `_page` singleton directly because `wearehere` injects init scripts (`addScriptToEvaluateOnNewDocument`) and network listeners that would pollute the session page for subsequent calls. The solution is to create a **second page tab** within the same browser instance.
18
+
19
+ ## Proposed Solution
20
+ 1. **Session-aware page creation** — Instead of `connect()`, assess opens a new CDP tab within the existing browser. This shares the browser process (same cookies, same headed/headless state) but isolates assess's script injections to its own tab.
21
+ 2. **Retry with backoff** — Wrap the assess call in a retry loop (max 2 attempts, 2s backoff). On browser crash, reconnect the singleton.
22
+ 3. **Timeout guard** — Wrap each assess call in `Promise.race` with a 45s hard deadline. If exceeded, return an error result (not hang).
23
+
24
+ ## Benefits
25
+ - Assess gets cookies and headed fallback for free — no separate browser instance
26
+ - Failed assessments auto-retry instead of dying
27
+ - Hanging assessments time out gracefully instead of blocking the MCP server forever
28
+ - Eliminates the 10+ second cold-start per assessment (browser launch)
29
+
30
+ ## Scope
31
+ ### In Scope
32
+ - Modify `mcp-server.js` assess handler to create tabs within existing browser
33
+ - Add `createTab()` / `closeTab()` helper to `src/index.js` connect() page handle
34
+ - Add retry wrapper in mcp-server.js
35
+ - Add timeout guard in mcp-server.js
36
+ - Update docs: README.md, barebrowse.context.md, CLAUDE.md
37
+
38
+ ### Out of Scope
39
+ - Changing wearehere's internal logic
40
+ - Adding retry/self-healing to other MCP tools (future work)
41
+ - Batch/queue mode for multiple assessments
42
+ - Changing the assess tool's MCP interface (same inputs/outputs)
43
+
44
+ ## Dependencies
45
+ - `wearehere` package (assess function signature unchanged)
46
+ - `src/index.js` connect() API (adding createTab/closeTab methods)
47
+ - `src/cdp.js` (Target.createTarget / closeTarget already available)
48
+
49
+ ## Implementation Strategy
50
+ Phase 1: Add tab management to connect() page handle (createTab, closeTab)
51
+ Phase 2: Rewrite assess handler to use session tab + retry + timeout
52
+ Phase 3: Update documentation
53
+
54
+ ## Risks and Mitigations
55
+ | Risk | Impact | Mitigation |
56
+ |------|--------|------------|
57
+ | Init script injection leaks across tabs | Pollutes session page | Each tab gets its own Page domain; addScriptToEvaluateOnNewDocument is per-target |
58
+ | Browser crash during assess kills session too | Session page lost | getPage() already handles reconnection lazily (set _page = null, next call recreates) |
59
+ | wearehere expects full page handle, not raw CDP session | API mismatch | createTab() returns a page-like object with goto, cdp, waitForNetworkIdle — same interface |
60
+
61
+ ## Success Criteria
62
+ - [ ] `assess` reuses the session browser (no separate `connect()` call)
63
+ - [ ] `assess` inherits cookies from the session
64
+ - [ ] `assess` works when session is in headed mode (hybrid fallback already triggered)
65
+ - [ ] Failed assessment retries once before returning error
66
+ - [ ] Assessment hanging > 45s returns timeout error, doesn't block server
67
+ - [ ] All existing tests pass
68
+ - [ ] Documentation updated
69
+
70
+ ## Open Questions
71
+ 1. Should createTab() also inject cookies? — **Recommendation**: Yes, call `authenticate()` for the target URL before navigation, same as `goto` does.
@@ -0,0 +1,38 @@
1
+ # PRD: Harden assess tool
2
+
3
+ ## Overview
4
+ The `assess` MCP tool must reuse the session browser, retry on failure, and time out gracefully.
5
+
6
+ ## Requirements
7
+
8
+ ### R1: Session-aware tab creation
9
+ The assess tool MUST create a new browser tab within the existing MCP session browser instead of spawning a separate browser via `connect()`. The tab MUST:
10
+ - Share the same browser process (inheriting headless/headed state)
11
+ - Have access to the browser's cookie jar
12
+ - Isolate its CDP domains (Page, Network, DOM) from the session page
13
+ - Be closed after each assessment completes or fails
14
+
15
+ ### R2: Cookie injection
16
+ Before navigating, the assess tab MUST inject cookies from the user's browser for the target URL, using the same `authenticate()` mechanism as `goto`.
17
+
18
+ ### R3: Retry on failure
19
+ If an assessment fails (navigation timeout, CDP error, browser crash), the tool MUST:
20
+ - Retry once after a 2-second delay
21
+ - If the browser crashed, reset the session singleton (`_page = null`) so getPage() reconnects
22
+ - If retry also fails, return a structured error result (not throw)
23
+
24
+ ### R4: Timeout guard
25
+ Each assessment MUST have a hard timeout of 45 seconds. If exceeded:
26
+ - The tab is force-closed
27
+ - A structured error result is returned: `{ site, url, error: "timeout", scanned_at }`
28
+ - The session page is NOT affected
29
+
30
+ ### R5: Backwards compatibility
31
+ - The assess tool's MCP interface (inputs/outputs) MUST NOT change
32
+ - Successful assessments return the same JSON format as before
33
+ - The tool appears/disappears based on wearehere availability (unchanged)
34
+
35
+ ## Non-functional
36
+ - No new dependencies
37
+ - No changes to wearehere package
38
+ - createTab()/closeTab() exposed on connect() page handle for library users too
package/CHANGELOG.md CHANGED
@@ -1,5 +1,49 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.5
4
+
5
+ Fix assess tab leak and Linux shared memory crash.
6
+
7
+ ### Assess tab leak (`mcp-server.js`)
8
+ - Fixed: successful assess calls never closed the tab — tabs accumulated, eating RAM until Chromium crashed
9
+ - `tab.close()` now called in the success path (was only in error/timeout paths)
10
+ - This was the root cause of crashes on heavy EU cookie consent sites (zalando.de, otto.de, etc.) — not the CMPs themselves
11
+
12
+ ### Chromium launch (`src/chromium.js`)
13
+ - Added `--disable-dev-shm-usage` flag — prevents shared memory crashes on Linux systems with limited `/dev/shm`
14
+
15
+ ### Tests
16
+ - New: `createTab()` suite in browse.test.js (2 tests)
17
+ - Creates 5 tabs, navigates each, closes all, verifies no zombie tabs remain
18
+ - Tab close is idempotent (double-close doesn't throw)
19
+ - 71/71 passing (was 69)
20
+
21
+ ## 0.5.4
22
+
23
+ Assess tool hardened: session reuse, concurrency, self-healing.
24
+
25
+ ### Assess handler (`mcp-server.js`)
26
+ - Session reuse: assess now opens tabs in the existing session browser via `createTab()` instead of spawning a new browser per scan
27
+ - Concurrency: semaphore limits to 3 concurrent assess tabs, queues the rest
28
+ - 30s hard timeout per scan with force tab close on expiry
29
+ - Auto-retry once on failure with 2s backoff; resets session on CDP crash
30
+ - Removed debug logging added during development
31
+
32
+ ### CDP resilience (`src/cdp.js`)
33
+ - `ws.onclose` handler rejects all pending CDP promises — prevents zombie promises on browser crash
34
+
35
+ ### Library API (`src/index.js`)
36
+ - `createTab()` added to `connect()` return object — creates new tab in same browser session
37
+ - Returns `{ goto, injectCookies, waitForNetworkIdle, cdp, close }`, tab close doesn't affect main page
38
+
39
+ ### Message loop (`mcp-server.js`)
40
+ - `getPage()` is concurrency-safe with promise dedup (prevents duplicate browser launches)
41
+ - Message loop changed from sequential `await` to concurrent `.then()` fire-and-forget — multiple tool calls no longer block each other
42
+
43
+ ### Tests
44
+ - 69/69 passing
45
+ - Verified: 10 concurrent assess calls through MCP client, all succeed (3-at-a-time semaphore confirmed)
46
+
3
47
  ## 0.5.3
4
48
 
5
49
  Improved bot detection for hybrid mode fallback.
package/README.md CHANGED
@@ -139,7 +139,7 @@ Everything the agent can do through barebrowse:
139
139
  | **Upload** | Set files on a file input element |
140
140
  | **Screenshot** | Page capture as base64 PNG/JPEG/WebP |
141
141
  | **PDF** | Export page as PDF |
142
- | **Assess** | Privacy scan: score (0-100), risk level, 10-category breakdown. Requires `npm install wearehere`. |
142
+ | **Assess** | Privacy scan: score (0-100), risk level, 10-category breakdown. Reuses session browser via tabs (max 3 concurrent, properly closed after each scan), auto-retries on CDP crash, 30s timeout per scan. Requires `npm install wearehere`. |
143
143
  | **Tabs** | List open tabs, switch between them |
144
144
  | **Wait for content** | Poll for text or CSS selector to appear on page |
145
145
  | **Wait for navigation** | SPA-aware: works for full page loads and pushState |
@@ -1,7 +1,7 @@
1
1
  # barebrowse -- Integration Guide
2
2
 
3
3
  > For AI assistants and developers wiring barebrowse into a project.
4
- > v0.5.3 | Node.js >= 22 | 0 required deps | MIT
4
+ > v0.5.5 | Node.js >= 22 | 0 required deps | MIT
5
5
 
6
6
  ## What this is
7
7
 
@@ -78,6 +78,7 @@ const snapshot = await browse('https://example.com', {
78
78
  | `injectCookies(url, opts?)` | url: string, { browser?: string } | void | Extract cookies from user's browser and inject via CDP |
79
79
  | `dialogLog` | -- | Array<{type, message, timestamp}> | Auto-dismissed JS dialog history |
80
80
  | `cdp` | -- | object | Raw CDP session for escape hatch: `page.cdp.send(method, params)` |
81
+ | `createTab()` | -- | tab handle | New tab in same browser. Returns `{ goto, injectCookies, waitForNetworkIdle, cdp, close }`. Tab close doesn't affect session. |
81
82
  | `close()` | -- | void | Close page, disconnect CDP, kill browser (if headless) |
82
83
 
83
84
  **connect() options** (in addition to mode/port/consent):
@@ -156,6 +157,7 @@ barebrowse can inject cookies from the user's real browser sessions, bypassing l
156
157
  | Bot detection | Hybrid fallback: detects challenge pages, error pages, and near-empty responses, then switches to headed | Hybrid |
157
158
  | `navigator.webdriver` | Stealth patches in headless (webdriver, plugins, chrome obj) | Headless |
158
159
  | Profile locking | Unique temp dir per headless instance | Headless |
160
+ | Shared memory crash (Linux) | `--disable-dev-shm-usage` flag prevents `/dev/shm` exhaustion | Headless |
159
161
  | ARIA noise | 9-step pruning: wrapper collapse, noise removal, landmark promotion | Both |
160
162
 
161
163
  ## bareagent wiring
@@ -241,7 +243,7 @@ Action tools return `'ok'` -- the agent calls `snapshot` explicitly to observe.
241
243
 
242
244
  Session runs in hybrid mode (headless with automatic headed fallback on bot detection). `goto` injects cookies from the user's browser before navigation for authenticated access.
243
245
 
244
- Session tools share a singleton page, lazy-created on first use.
246
+ Session tools share a singleton page, lazy-created on first use. Assess runs in isolated tabs within the session (max 3 concurrent, with retry and CDP crash recovery). Tabs are closed after every assess (success, error, and timeout paths).
245
247
 
246
248
  ## Architecture
247
249
 
@@ -271,7 +273,7 @@ URL -> chromium.js (find/launch browser, permission flags)
271
273
  | `src/consent.js` | 200 | Auto-dismiss cookie consent dialogs across languages |
272
274
  | `src/stealth.js` | ~40 | Navigator patches for headless anti-detection |
273
275
  | `src/bareagent.js` | ~250 | Tool adapter for bareagent Loop |
274
- | `mcp-server.js` | ~170 | MCP server (JSON-RPC over stdio) |
276
+ | `mcp-server.js` | ~340 | MCP server (JSON-RPC over stdio, assess session reuse + concurrency) |
275
277
 
276
278
  ## Privacy assessment (optional)
277
279
 
@@ -281,7 +283,7 @@ Install `wearehere` to add an `assess` tool to both the MCP server and bareagent
281
283
  npm install wearehere
282
284
  ```
283
285
 
284
- The `assess` tool navigates to a URL in an isolated browser page, scans for 10 privacy categories (cookies, trackers, fingerprinting, dark patterns, data brokers, form surveillance, link tracking, toxic terms, stored data, network traffic), and returns a compact JSON assessment:
286
+ The `assess` tool opens a new tab in the session browser via `createTab()` (reusing cookies and headed fallback), scans for 10 privacy categories (cookies, trackers, fingerprinting, dark patterns, data brokers, form surveillance, link tracking, toxic terms, stored data, network traffic), and returns a compact JSON assessment. Max 3 concurrent scans (queued beyond that), 30s hard timeout per scan, auto-retry once on failure with 2s backoff (session reset on CDP crash):
285
287
 
286
288
  ```json
287
289
  {
package/mcp-server.js CHANGED
@@ -20,6 +20,11 @@ try {
20
20
  } catch {}
21
21
 
22
22
 
23
+ function isCdpDead(err) {
24
+ const m = err.message || '';
25
+ return m.includes('WebSocket') || m.includes('Target closed') || m.includes('Session closed') || m.includes('CDP');
26
+ }
27
+
23
28
  const MAX_CHARS_DEFAULT = 30000;
24
29
  const OUTPUT_DIR = join(process.cwd(), '.barebrowse');
25
30
 
@@ -32,10 +37,42 @@ function saveSnapshot(text) {
32
37
  }
33
38
 
34
39
  let _page = null;
40
+ let _pageConnecting = null;
35
41
 
36
42
  async function getPage() {
37
- if (!_page) _page = await connect({ mode: 'hybrid' });
38
- return _page;
43
+ if (_page) return _page;
44
+ if (_pageConnecting) return _pageConnecting;
45
+ _pageConnecting = connect({ mode: 'hybrid' });
46
+ try {
47
+ _page = await _pageConnecting;
48
+ return _page;
49
+ } catch (err) {
50
+ _page = null;
51
+ throw err;
52
+ } finally {
53
+ _pageConnecting = null;
54
+ }
55
+ }
56
+
57
+ // Concurrency limiter for assess — max 3 tabs at once
58
+ const ASSESS_MAX = 3;
59
+ let _assessRunning = 0;
60
+ const _assessQueue = [];
61
+
62
+ function acquireAssessSlot() {
63
+ if (_assessRunning < ASSESS_MAX) {
64
+ _assessRunning++;
65
+ return Promise.resolve();
66
+ }
67
+ return new Promise((resolve) => _assessQueue.push(resolve));
68
+ }
69
+
70
+ function releaseAssessSlot() {
71
+ if (_assessQueue.length > 0) {
72
+ _assessQueue.shift()();
73
+ } else {
74
+ _assessRunning--;
75
+ }
39
76
  }
40
77
 
41
78
  const TOOLS = [
@@ -255,15 +292,48 @@ async function handleToolCall(name, args) {
255
292
  }
256
293
  case 'assess': {
257
294
  if (!assessFn) throw new Error('wearehere is not installed. Run: npm install wearehere');
258
- const page = await connect({ mode: 'hybrid' });
295
+ await acquireAssessSlot();
259
296
  try {
260
- const result = await assessFn(page, args.url, {
261
- timeout: args.timeout,
262
- settle: args.settle,
263
- });
264
- return JSON.stringify(result, null, 2);
297
+ const runAssess = async () => {
298
+ const page = await getPage();
299
+ const tab = await page.createTab();
300
+ let timer;
301
+ try {
302
+ const result = await Promise.race([
303
+ (async () => {
304
+ await tab.injectCookies(args.url).catch(() => {});
305
+ return await assessFn(tab, args.url, { timeout: args.timeout, settle: args.settle });
306
+ })(),
307
+ new Promise((_, reject) => {
308
+ timer = setTimeout(() => {
309
+ tab.close().catch(() => {});
310
+ reject(new Error('assess timeout'));
311
+ }, 30000);
312
+ }),
313
+ ]);
314
+ clearTimeout(timer);
315
+ await tab.close().catch(() => {});
316
+ return JSON.stringify(result, null, 2);
317
+ } catch (err) {
318
+ clearTimeout(timer);
319
+ await tab.close().catch(() => {});
320
+ throw err;
321
+ }
322
+ };
323
+ try {
324
+ return await runAssess();
325
+ } catch (err) {
326
+ if (isCdpDead(err)) _page = null;
327
+ await new Promise((r) => setTimeout(r, 2000));
328
+ try {
329
+ return await runAssess();
330
+ } catch (retryErr) {
331
+ if (isCdpDead(retryErr)) _page = null;
332
+ throw retryErr;
333
+ }
334
+ }
265
335
  } finally {
266
- await page.close().catch(() => {});
336
+ releaseAssessSlot();
267
337
  }
268
338
  }
269
339
  default:
@@ -286,7 +356,7 @@ async function handleMessage(msg) {
286
356
  return jsonrpcResponse(id, {
287
357
  protocolVersion: '2024-11-05',
288
358
  capabilities: { tools: {} },
289
- serverInfo: { name: 'barebrowse', version: '0.5.3' },
359
+ serverInfo: { name: 'barebrowse', version: '0.5.5' },
290
360
  });
291
361
  }
292
362
 
@@ -321,8 +391,9 @@ async function handleMessage(msg) {
321
391
  let buffer = '';
322
392
 
323
393
  process.stdin.setEncoding('utf8');
324
- process.stdin.on('data', async (chunk) => {
394
+ process.stdin.on('data', (chunk) => {
325
395
  buffer += chunk;
396
+
326
397
  let newlineIdx;
327
398
  while ((newlineIdx = buffer.indexOf('\n')) !== -1) {
328
399
  const line = buffer.slice(0, newlineIdx).trim();
@@ -331,11 +402,19 @@ process.stdin.on('data', async (chunk) => {
331
402
 
332
403
  try {
333
404
  const msg = JSON.parse(line);
334
- const response = await handleMessage(msg);
335
- if (response) {
336
- process.stdout.write(response + '\n');
337
- }
405
+
406
+ handleMessage(msg).then((response) => {
407
+ if (response) {
408
+
409
+ process.stdout.write(response + '\n');
410
+
411
+ }
412
+ }).catch((err) => {
413
+
414
+ process.stdout.write(jsonrpcError(msg.id, -32700, `Error: ${err.message}`) + '\n');
415
+ });
338
416
  } catch (err) {
417
+
339
418
  process.stdout.write(jsonrpcError(null, -32700, `Parse error: ${err.message}`) + '\n');
340
419
  }
341
420
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "barebrowse",
3
- "version": "0.5.3",
3
+ "version": "0.5.5",
4
4
  "description": "Authenticated web browsing for autonomous agents via CDP. URL in, pruned ARIA snapshot out.",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/cdp.js CHANGED
@@ -71,6 +71,13 @@ export async function createCDP(wsUrl) {
71
71
  }
72
72
  };
73
73
 
74
+ ws.onclose = () => {
75
+ for (const [id, handler] of pending) {
76
+ handler.reject(new Error('CDP WebSocket closed'));
77
+ pending.delete(id);
78
+ }
79
+ };
80
+
74
81
  const client = {
75
82
  /**
76
83
  * Send a CDP command and wait for the response.
package/src/chromium.js CHANGED
@@ -82,6 +82,7 @@ export async function launch(opts = {}) {
82
82
  '--use-fake-device-for-media-stream',
83
83
  '--use-fake-ui-for-media-stream',
84
84
  '--disable-features=MediaRouter',
85
+ '--disable-dev-shm-usage',
85
86
  ];
86
87
 
87
88
  if (opts.proxy) {
package/src/index.js CHANGED
@@ -365,6 +365,26 @@ export async function connect(opts = {}) {
365
365
  /** Raw CDP session for escape hatch */
366
366
  cdp: page.session,
367
367
 
368
+ async createTab() {
369
+ const tab = await createPage(cdp, mode !== 'headed', { viewport: opts.viewport });
370
+ await suppressPermissions(cdp);
371
+ return {
372
+ async goto(url, timeout = 30000) {
373
+ await navigate(tab, url, timeout);
374
+ },
375
+ async injectCookies(url, cookieOpts) {
376
+ await authenticate(tab.session, url, { browser: cookieOpts?.browser });
377
+ },
378
+ waitForNetworkIdle(idleOpts = {}) {
379
+ return waitForNetworkIdle(tab.session, idleOpts);
380
+ },
381
+ cdp: tab.session,
382
+ async close() {
383
+ await cdp.send('Target.closeTarget', { targetId: tab.targetId });
384
+ },
385
+ };
386
+ },
387
+
368
388
  async close() {
369
389
  await cdp.send('Target.closeTarget', { targetId: page.targetId });
370
390
  cdp.close();