@crawlee/browser 4.0.0-beta.164 → 4.0.0-beta.166

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.
@@ -11,10 +11,12 @@ interface BaseResponse {
11
11
  }
12
12
  /**
13
13
  * The type of a browser pool the crawler builds (and therefore owns) for itself. It's an {@link IBrowserPool} that
14
- * additionally exposes `destroy()` — the crawler only ever tears down pools it created, which is why {@link IBrowserPool}
15
- * itself intentionally omits `destroy`.
14
+ * additionally exposes the lifecycle hooks a crawler only ever calls on a pool it created — which is why
15
+ * {@link IBrowserPool} itself intentionally omits them: `releaseAllBrowsers()` at the end of every run, and
16
+ * `destroy()` once the crawler itself is destroyed.
16
17
  */
17
18
  export type OwnedBrowserPool<Page> = IBrowserPool<Page> & {
19
+ releaseAllBrowsers: () => Promise<void>;
18
20
  destroy: () => Promise<void>;
19
21
  };
20
22
  /**
@@ -417,10 +419,11 @@ export declare abstract class BrowserCrawler<Page extends CommonPage = CommonPag
417
419
  protected abstract navigationHandler(crawlingContext: BrowserCrawlingContext<Page, Response>, gotoOptions: GoToOptions): Promise<Context['response'] | null | undefined>;
418
420
  private processResponse;
419
421
  /**
420
- * Function for cleaning up after all requests are processed.
421
- * @ignore
422
+ * Closes the browsers of a pool the crawler owns, so a finished run leaves none behind. The pool itself is
423
+ * crawler-lifetime and survives — destroying it here would hand a repeated `run()` a dead pool.
422
424
  */
423
425
  teardown(): Promise<void>;
426
+ destroy(): Promise<void>;
424
427
  }
425
428
  /**
426
429
  * Extracts URLs from a given page.
@@ -431,13 +431,17 @@ export class BrowserCrawler extends BasicCrawler {
431
431
  request.loadedUrl = await page.url();
432
432
  }
433
433
  /**
434
- * Function for cleaning up after all requests are processed.
435
- * @ignore
434
+ * Closes the browsers of a pool the crawler owns, so a finished run leaves none behind. The pool itself is
435
+ * crawler-lifetime and survives — destroying it here would hand a repeated `run()` a dead pool.
436
436
  */
437
437
  async teardown() {
438
- await this.#browserPoolDep.ifOwned((pool) => pool.destroy());
438
+ await this.#browserPoolDep.ifOwned((pool) => pool.releaseAllBrowsers());
439
439
  await super.teardown();
440
440
  }
441
+ async destroy() {
442
+ await super.destroy();
443
+ await this.#browserPoolDep.ifOwned((pool) => pool.destroy());
444
+ }
441
445
  }
442
446
  /**
443
447
  * Extracts URLs from a given page.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crawlee/browser",
3
- "version": "4.0.0-beta.164",
3
+ "version": "4.0.0-beta.166",
4
4
  "description": "The scalable web crawling and scraping library for JavaScript/Node.js. Enables development of data extraction and web automation jobs (not only) with headless Chrome and Puppeteer.",
5
5
  "engines": {
6
6
  "node": ">=22.0.0"
@@ -47,14 +47,14 @@
47
47
  "access": "public"
48
48
  },
49
49
  "dependencies": {
50
- "@apify/timeout": "^0.4.4",
51
- "@crawlee/basic": "4.0.0-beta.164",
52
- "@crawlee/browser-pool": "4.0.0-beta.164",
53
- "@crawlee/types": "4.0.0-beta.164",
54
- "@crawlee/utils": "4.0.0-beta.164",
50
+ "@apify/timeout": "^1.0.1",
51
+ "@crawlee/basic": "4.0.0-beta.166",
52
+ "@crawlee/browser-pool": "4.0.0-beta.166",
53
+ "@crawlee/types": "4.0.0-beta.166",
54
+ "@crawlee/utils": "4.0.0-beta.166",
55
55
  "tslib": "^2.8.1",
56
56
  "type-fest": "^4.41.0",
57
- "zod": "^4.4.3"
57
+ "zod": "^4.5.4"
58
58
  },
59
59
  "peerDependencies": {
60
60
  "playwright": "*",
@@ -75,5 +75,5 @@
75
75
  }
76
76
  }
77
77
  },
78
- "gitHead": "a2e4e2a3aa3a364c8a44fd2e49ca57f500d2c01f"
78
+ "gitHead": "5d34cf3b9da170f22cf5b346014ba44060dad827"
79
79
  }