@crawlee/cli 4.0.0-rc.2 → 4.0.0-rc.3

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,174 @@
1
+ ---
2
+ id: browser-management
3
+ title: 'Upgrading to v4: browser management'
4
+ sidebar_label: Browser management
5
+ sidebar_position: 3
6
+ slug: /upgrading/upgrading-to-v4/browser-management
7
+ ---
8
+
9
+ Applies when you construct a `BrowserPool` yourself, reach for `browserController`, or tune `AdaptivePlaywrightCrawler` internals. This page is part of the [Upgrading to v4](./upgrading-v4.md) guide.
10
+
11
+ ## Custom `BrowserPool` implementations via the `IBrowserPool` interface
12
+
13
+ Browser crawlers now accept any object implementing the new `IBrowserPool` interface as their `browserPool` option, not just instances of the built-in `BrowserPool`. The interface follows the classic acquire/release pattern, plus a pair of helpers for moving state between the crawling session and the page:
14
+
15
+ - **`newPage(options?)`** — opens a new page. An optional `session` can be passed as a best-effort hint — the pool may use it for proxy configuration, fingerprinting, etc., but nothing is guaranteed.
16
+ - **`closePage(page, options?)`** — signals the pool that the caller is done with the page. If the optional `error` is a `SessionError`, the session that served the page is finished. A plain `SessionError` means it was blocked, so the pool should purge all state associated with it (e.g. retire the underlying browser). The `SessionRetiredError` subclass means the session merely reached its `maxUsageCount` or `maxAgeSecs`, and a pool may keep a warm page instead.
17
+ - **`extractPageState(page)`** — reads the relevant state (currently cookies) out of a page so the crawler can persist it back into the session.
18
+ - **`injectPageState(page, state)`** — the counterpart to `extractPageState`; seeds a page with state (currently cookies) before navigation. Isolation between pages is best-effort and depends on the pool implementation.
19
+
20
+ Lifecycle (`destroy`) is the responsibility of whoever owns the pool: a custom pool you construct yourself is never owned by the crawler, so the crawler never tears it down. This makes it straightforward to plug in a remote browser farm, a session-aware pool, or another custom browser-management strategy without subclassing `BrowserPool`.
21
+
22
+ ```typescript
23
+ import { PuppeteerCrawler } from '@crawlee/puppeteer';
24
+ import { BrowserPool, PuppeteerPlugin, type IBrowserPool } from '@crawlee/browser-pool';
25
+ import puppeteer from 'puppeteer';
26
+
27
+ const sharedPool = new BrowserPool({ browserPlugins: [new PuppeteerPlugin(puppeteer)] });
28
+
29
+ const crawler = new PuppeteerCrawler({
30
+ browserPool: sharedPool,
31
+ requestHandler: async ({ page }) => {
32
+ // …
33
+ },
34
+ });
35
+
36
+ // You own `sharedPool` — destroy it yourself when you're done.
37
+ await crawler.run();
38
+ await sharedPool.destroy();
39
+ ```
40
+
41
+ The `crawler.browserPool` property is now **read-only** (a getter). It was previously a writable field, so any code that reassigned it after construction (`crawler.browserPool = myPool`) no longer works — pass your pool via the `browserPool` constructor option instead.
42
+
43
+ ## `@crawlee/browser-pool` is no longer re-exported from `crawlee`
44
+
45
+ The meta-package used to `export *` from `@crawlee/browser-pool`, which made `BrowserPool`, `PuppeteerPlugin`, `PlaywrightPlugin`, `BrowserController`, `LaunchContext`, the fingerprint enums and the `IBrowserPool` / `NewPageOptions` interfaces importable from `crawlee`. They no longer are. Add `@crawlee/browser-pool` to your dependencies and import them from there:
46
+
47
+ ```diff
48
+ -import { BrowserPool, PlaywrightPlugin } from 'crawlee';
49
+ +import { BrowserPool, PlaywrightPlugin } from '@crawlee/browser-pool';
50
+ ```
51
+
52
+ The crawler-facing factories `playwrightBrowserPool()` and `puppeteerBrowserPool()` still come from `crawlee` and their respective crawler packages. For a remote connection, pass `remoteBrowser` to the regular factory; there are no separate `remote*BrowserPool()` functions. Building a pool this way needs no extra dependency.
53
+
54
+ ## `BrowserCrawlingContext.browserController` has been removed
55
+
56
+ The `browserController` property is no longer part of the crawling context (`BrowserCrawlingContext`). Browser controller management is now fully internal to the pool — the crawler interacts with the pool only through the `IBrowserPool` interface (`newPage`, `closePage`, `extractPageState`, and `injectPageState`).
57
+
58
+ If you previously used `browserController` in your request handlers, here is how to migrate the most common patterns:
59
+
60
+ **Cookies** — Cookie injection and persistence are now handled automatically by the crawler and the pool. You no longer need to call `browserController.getCookies()` or `browserController.setCookies()` manually.
61
+
62
+ **Proxy info** — Access proxy information via `session.proxyInfo` instead of `browserController.launchContext.proxyUrl`. TLS-error handling moved along with it: the pool reads `session.proxyInfo.ignoreTlsErrors`, so the `IBrowserPool` `newPage()` options have no `ignoreTlsErrors` field (the built-in `BrowserPool.newPage()` still accepts one as an explicit override). If you need to disable TLS verification for some other reason, set `ignoreHTTPSErrors` (Playwright) / `acceptInsecureCerts` (Puppeteer) through the browser's `launchOptions`.
63
+
64
+ **Direct browser access** — If you need the raw browser or controller instance (e.g. for Puppeteer/Playwright-specific APIs), construct a `BrowserPool` yourself, pass it to the crawler, and reference it directly in your handler — no cast needed:
65
+
66
+ ```typescript
67
+ import { BrowserPool, PuppeteerPlugin } from '@crawlee/browser-pool';
68
+ import { PuppeteerCrawler } from '@crawlee/puppeteer';
69
+ import puppeteer from 'puppeteer';
70
+
71
+ const pool = new BrowserPool({ browserPlugins: [new PuppeteerPlugin(puppeteer)] });
72
+
73
+ const crawler = new PuppeteerCrawler({
74
+ browserPool: pool,
75
+ requestHandler: async ({ page }) => {
76
+ const controller = pool.getBrowserControllerByPage(page);
77
+ // controller.browser, controller.launchContext, etc.
78
+ },
79
+ });
80
+
81
+ await crawler.run();
82
+ // You own the pool — tear it down yourself.
83
+ await pool.destroy();
84
+ ```
85
+
86
+ Note that this couples your code to the built-in `BrowserPool` — custom `IBrowserPool` implementations may not expose controllers at all.
87
+
88
+ ## Puppeteer cookies are now read and written at the browser-context level
89
+
90
+ The `PuppeteerController._getCookies` / `_setCookies` methods (used internally by the session pool to sync cookies between a `Session` and a Puppeteer page) now call `page.browserContext().cookies()` / `setCookie()` instead of the deprecated `page.cookies()` / `page.setCookie()`. The page-level API was removed in newer Puppeteer releases.
91
+
92
+ This aligns the Puppeteer controller with the Playwright controller, which has always worked at the context level.
93
+
94
+ **What changes in practice**
95
+ - Cookie reads return every cookie stored in the page's browser context, not just cookies matching the page's current URL. If your `Session` relied on the URL-scoped filtering (for example, to avoid pulling cookies that belong to other tabs in the same context), you'll now see the full set.
96
+ - Cookie writes are applied to the whole browser context. When pages share a context, cookies the crawler syncs from a session's cookie jar are visible to every other page in that context.
97
+
98
+ With `useIncognitoPages: true`, each page gets its own browser context, so each session owns its cookies and you should not notice any difference. With the default `useIncognitoPages: false`, pages share the browser's default context, so cookies written for one session become visible to other sessions' pages in that browser.
99
+
100
+ **Cookie `url` field** — the old `page.setCookie()` auto-filled a missing `url` on each cookie with the page's current URL. The new `browserContext().setCookie()` does not; Chromium rejects cookies that carry neither `url` nor `domain`. Crawlee's internal `_setCookies` keeps the old behavior by back-filling `page.url()` for any cookie that has neither field set, but if you call `browserContext().setCookie()` directly (outside of Crawlee) you need to provide one of them yourself.
101
+
102
+ ## Custom rendering type predictors via the `IRenderingTypePredictor` interface
103
+
104
+ The `renderingTypePredictor` option of `AdaptivePlaywrightCrawler` is now typed as the new `IRenderingTypePredictor` interface — `predict(request)` and `storeResult(requests, renderingType)`, nothing else, either of which may return a promise. The built-in `RenderingTypePredictor` implements it, so passing one still works.
105
+
106
+ What changed is the lifecycle: the crawler used to call `initialize()` on the predictor it was given, even though it did not create it. It now follows the same own-only-what-you-built rule as the session and browser pools — a predictor you pass in is *borrowed*, so setting it up is your job, and `initialize` is not part of the interface at all. The built-in predictor restores its persisted state in `initialize()` and will throw `Recoverable state has not yet been loaded` from `predict()` if it is never called:
107
+
108
+ ```typescript
109
+ import { AdaptivePlaywrightCrawler, RenderingTypePredictor } from '@crawlee/playwright';
110
+
111
+ const renderingTypePredictor = new RenderingTypePredictor({ detectionRatio: 0.1 });
112
+ // You own the predictor — initialize it yourself (this used to be done by the crawler).
113
+ await renderingTypePredictor.initialize();
114
+
115
+ const crawler = new AdaptivePlaywrightCrawler({
116
+ renderingTypePredictor,
117
+ requestHandler: async ({ pushData }) => {
118
+ // …
119
+ },
120
+ });
121
+ ```
122
+
123
+ If you don't pass a predictor, nothing changes: the crawler builds one from `renderingTypeDetectionRatio` and, since it owns that one, initializes it for you.
124
+
125
+ **Asynchronous predictors** — `predict()` is awaited before the crawler routes the request, so prefer loading whatever it needs up front over per-request I/O. `storeResult()` is *not* awaited per detection: the crawler tracks the promise it returns and drains everything still pending in `teardown()`, so a predictor that batches its writes can rely on them landing before the crawl ends. That wait is bounded by the internal timeout (`CRAWLEE_INTERNAL_TIMEOUT`), `crawler.drainRenderingDetections()` performs it on demand, and `crawler.inFlightRenderingTypeDetectionCount` reports what is still outstanding.
126
+
127
+ `teardown()` stops new detections from starting before it drains, so ending a `keepAlive` crawl by tearing it down from outside `run()` cannot leave a detection unpersisted either.
128
+
129
+ ## Remove `experimentalContainers` option
130
+
131
+ This experimental option relied on an outdated manifest version for browser extensions, it is not possible to achieve this with the currently supported versions.
132
+
133
+ ## `PlaywrightLauncher` is no longer exported
134
+
135
+ `PlaywrightLauncher` was an implementation detail of `launchPlaywright()` and the Playwright browser pools, and it is no longer part of `@crawlee/playwright`'s (or `crawlee`'s) public exports. Use `launchPlaywright(launchContext, configuration)` to get a `Browser`, or `playwrightBrowserPool()` when you need a pool. `PlaywrightLaunchContext` is still exported, so the options object can still be typed.
136
+
137
+ ## `BrowserCrawler.launchContext` was removed
138
+
139
+ The `launchContext` property on crawler instances is gone. The `launchContext` **option** is unchanged on `PlaywrightCrawler`, `PuppeteerCrawler` and `StagehandCrawler` — only the echo of it on the instance is gone. If you were reading `crawler.launchContext`, keep your own reference to the object you passed in.
140
+
141
+ The abstract `BrowserCrawler` base class also lost its `LaunchOptions` type parameter, which existed only to type that field, along with `InternalBrowserPoolOptions`; its type parameters now start with the page and response types. Custom crawlers extending `BrowserCrawler` must update their type arguments:
142
+
143
+ ```diff
144
+ -class MyCrawler extends BrowserCrawler<BrowserPoolOptions, LaunchOptions, MyCrawlingContext> {
145
+ +class MyCrawler extends BrowserCrawler<Page, Response, MyCrawlingContext> {
146
+ ```
147
+
148
+ ## Unused browser options are now rejected instead of ignored
149
+
150
+ `PlaywrightCrawler` no longer accepts a top-level `launcher` option, and `PlaywrightLaunchContext` no longer accepts `launchContextOptions`; both were silently ignored and are now reported as unknown options by the constructors' validation. Pass the browser type as `launchContext.launcher`, and persistent-context settings inside `launchContext.launchOptions`.
151
+
152
+ ## Dead v3 fingerprinting types are removed
153
+
154
+ `BrowserSpecification`, `GetFingerprintReturn` and `@crawlee/browser-pool`'s own `FingerprintGenerator` interface (which shadowed `fingerprint-generator`'s class of the same name) are no longer exported. They had no consumers — `BrowserPool.fingerprintGenerator` is typed by `fingerprint-generator`'s `FingerprintGenerator`, and `fingerprintGeneratorOptions` is still typed by `FingerprintGeneratorOptions`.
155
+
156
+ ## `BROWSER_POOL_EVENTS.BROWSER_CLOSED` was removed
157
+
158
+ It was never emitted. Listen for `BROWSER_CONTROLLER_EVENTS.BROWSER_CLOSED` on a `BrowserController` instead.
159
+
160
+ ## `BrowserPool` internals are private
161
+
162
+ `pages`, `pageIds`, `pageCounter`, `pageToBrowserController`, `startingBrowserControllers`, `activeBrowserControllers`, `retiredBrowserControllers`, `operationTimeoutMillis`, `closeInactiveBrowserAfterMillis`, `maxOpenPagesPerBrowser`, `retireBrowserAfterPageCount` and `useFingerprints` are no longer readable or writable from outside the pool. Use `getPage()`, `getPageId()` and `getBrowserControllerByPage()` to reach pages, the `browserLaunched` / `browserRetired` / `pageCreated` / `pageClosed` events to observe the pool's lifecycle, and pass the corresponding `BrowserPoolOptions` at construction instead of assigning to the mirrors afterwards — the options themselves are unchanged.
163
+
164
+ The six hook arrays (`preLaunchHooks`, `postLaunchHooks`, `prePageCreateHooks`, `postPageCreateHooks`, `prePageCloseHooks`, `postPageCloseHooks`) are private too. Supply hooks through the constructor options; mutating or replacing the arrays on a live pool is no longer possible.
165
+
166
+ ```diff
167
+ -const browserPool = new BrowserPool({ browserPlugins: [plugin] });
168
+ -browserPool.postLaunchHooks.push(myHook);
169
+ +const browserPool = new BrowserPool({ browserPlugins: [plugin], postLaunchHooks: [myHook] });
170
+ ```
171
+
172
+ `BrowserController.log` and `BrowserPlugin.log` are no longer part of the public type surface either. Subclasses inside `@crawlee/browser-pool` still use them, but they are not covered by backwards-compatibility guarantees — get your own logger from `serviceLocator.getLogger()`.
173
+
174
+ Several more members are `@internal`, and remain present at runtime only: `BrowserPool.fingerprintInjector`, `.fingerprintCache`, `.fingerprintOptions`; `BrowserController.isActive`, `.totalPages`, `.lastPageOpenedAt`, `.normalizeProxyOptions()`; `AnonymizeProxySugarOptions`; and the `PlaywrightBrowser` constructor. The `_close` / `_kill` / `_newPage` / `_getCookies` / `_setCookies` hooks on `BrowserController` and the `_launch` / `addProxyToLaunchOptions` / `isChromiumBasedBrowser` hooks on `BrowserPlugin` are *not* in that list: they carry no release tag, on the abstract declarations and on the `PlaywrightController` / `PuppeteerController` / `PlaywrightPlugin` / `PuppeteerPlugin` overrides alike, and remain the extension contract for your own subclasses.
@@ -0,0 +1,108 @@
1
+ ---
2
+ id: http-clients
3
+ title: 'Upgrading to v4: HTTP clients'
4
+ sidebar_label: HTTP clients
5
+ sidebar_position: 5
6
+ slug: /upgrading/upgrading-to-v4/http-clients
7
+ ---
8
+
9
+ Applies when you implemented `BaseHttpClient` yourself, or imported `gotScraping` from `@crawlee/utils`. This page is part of the [Upgrading to v4](./upgrading-v4.md) guide.
10
+
11
+ ## HTTP client packages and `BaseHttpClient` reshaped
12
+
13
+ The HTTP client abstraction moved out of `@crawlee/core` into two new packages, and its shape changed to match the native `fetch` model.
14
+
15
+ - **`@crawlee/http-client`** (new) now owns the `BaseHttpClient` abstract base class, along with `FetchHttpClient`, `ResponseWithUrl`, and `CustomFetchOptions`.
16
+ - **`@crawlee/got-scraping-client`** (new) provides `GotScrapingHttpClient` — the `got-scraping`-backed client — as an opt-in dependency, so `got-scraping` is no longer pulled into every install.
17
+
18
+ `BaseHttpClient` was redesigned around `fetch`. In v3 it declared `sendRequest<TResponseType>(request): Promise<HttpResponse>` and `stream(request): Promise<StreamingHttpResponse>`; in v4 subclasses implement a single `protected abstract fetch(input: Request, init?): Promise<Response>` and the base class provides `sendRequest(request, options?): Promise<Response>`. There is no `stream()` method anymore — a `Response` already exposes `body` as a stream. The following symbols that were part of the old `@crawlee/core` HTTP surface are **removed**: `HttpResponse`, `StreamingHttpResponse`, `ResponseTypes` and `BaseHttpResponseData`. `processHttpRequestOptions` is no longer public either; it remains reachable from `@crawlee/utils/internal` without semver guarantees.
19
+
20
+ If you implemented a custom HTTP client:
21
+
22
+ **Before:**
23
+ ```typescript
24
+ import { BaseHttpClient, HttpRequest, HttpResponse } from '@crawlee/core';
25
+
26
+ class MyClient implements BaseHttpClient {
27
+ async sendRequest<T>(request: HttpRequest<T>): Promise<HttpResponse<T>> { /* ... */ }
28
+ async stream(request: HttpRequest) { /* ... */ }
29
+ }
30
+ ```
31
+
32
+ **After:**
33
+ ```typescript
34
+ import { BaseHttpClient, type CustomFetchOptions } from '@crawlee/http-client';
35
+
36
+ class MyClient extends BaseHttpClient {
37
+ protected async fetch(input: Request, init?: RequestInit & CustomFetchOptions): Promise<Response> {
38
+ // return a native Response; sendRequest() is inherited from BaseHttpClient
39
+ }
40
+ }
41
+ ```
42
+
43
+ ### Removed `@crawlee/types` HTTP types
44
+
45
+ The `RedirectHandler` type (exported from `@crawlee/core` in v3) has been removed. It was the redirect-callback type for `BaseHttpClient.stream()`, which no longer exists in v4 — a custom HTTP client now only implements `fetch()`, as shown above. If you referenced it, delete the reference; there is no replacement.
46
+
47
+ The `BrowserLikeResponse` interface has been removed. It was a v3-era shim for reading `url()` and `headers()` off a got-style response during cookie handling, and has had no consumer since HTTP responses became standard `Response` objects. Read `response.url` and `response.headers` directly instead.
48
+
49
+ ### Removed `HttpRequest` properties
50
+
51
+ The following properties have been removed from `HttpRequest`, as v4's HTTP client contract is `fetch`-shaped and read none of them:
52
+
53
+ - `headerGenerator`, `headerGeneratorOptions`, `useHeaderGenerator` — header and fingerprint generation is now the HTTP client implementation's concern. `ImpitHttpClient` derives headers from the session fingerprint automatically; configure it through the client's own constructor options.
54
+ - `sessionToken` — fingerprint stability is now keyed off the `Session` passed via `SendRequestOptions.session`.
55
+ - `insecureHTTPParser` — no longer supported; there is no equivalent in the `fetch`-based clients.
56
+ - `throwHttpErrors` — `sendRequest` never throws on an HTTP error status; inspect `response.status` yourself. The crawler's `additionalHttpErrorStatusCodes` / `ignoreHttpErrorStatusCodes` options only cover the crawled request itself.
57
+ - `responseType` (and the `HttpRequest<TResponseType>` type parameter) — read the body from the returned `Response` with `response.json()` / `response.text()` / `response.bytes()`.
58
+ - `maxRedirects` — redirect following is handled inside `BaseHttpClient.sendRequest` and capped at 10 redirects; it is no longer configurable per request.
59
+ - `encoding` — a `Response` has no decoding option. Decode the bytes yourself, e.g. `new TextDecoder('latin1').decode(await response.arrayBuffer())`.
60
+
61
+ `followRedirect` now only accepts a boolean. With `followRedirect: false`, `sendRequest` returns the redirect response instead of following it; the predicate form is gone.
62
+
63
+ ### Remaining `HttpRequest` properties changed type
64
+
65
+ `HttpRequest` and `HttpRequestOptions` (the first argument of `context.sendRequest()`) moved from `@crawlee/core` to `@crawlee/types`, and no longer accept arbitrary extra keys. The properties that stayed are no longer got-shaped:
66
+
67
+ | Property | v3 | v4 |
68
+ | --- | --- | --- |
69
+ | `headers` | plain object | a `Headers` instance — a plain object throws at runtime |
70
+ | `timeout` | got's object, e.g. `{ request: 5000 }` | a number of milliseconds |
71
+ | `body` | `string`, `Buffer`, `Readable`, generator or form data | `Readable` — wrap other values in `Readable.from()`, or use `json` / `form` |
72
+ | `cookieJar` | any got-compatible jar | a `tough-cookie` `CookieJar` |
73
+
74
+ **Before:**
75
+ ```typescript
76
+ await sendRequest({
77
+ url,
78
+ headers: { accept: 'application/json' },
79
+ timeout: { request: 5000 },
80
+ });
81
+ ```
82
+
83
+ **After:**
84
+ ```typescript
85
+ await sendRequest({
86
+ url,
87
+ headers: new Headers({ accept: 'application/json' }),
88
+ timeout: 5000,
89
+ });
90
+ ```
91
+
92
+ `followRedirect` and `encoding` are still declared, but nothing reads them: redirects are always followed, and the body is decoded when you call `response.text()` / `response.json()`.
93
+
94
+ ### `gotScraping` is no longer exported from `@crawlee/utils`
95
+
96
+ The `gotScraping` singleton previously exported from `@crawlee/utils` has been removed. If you used it as the crawler's HTTP client, use the new `GotScrapingHttpClient` instead:
97
+
98
+ ```typescript
99
+ import { CheerioCrawler } from 'crawlee';
100
+ import { GotScrapingHttpClient } from '@crawlee/got-scraping-client';
101
+
102
+ const crawler = new CheerioCrawler({
103
+ httpClient: new GotScrapingHttpClient(),
104
+ requestHandler: async ({ $ }) => { /* ... */ },
105
+ });
106
+ ```
107
+
108
+ If you called `gotScraping(...)` directly for one-off requests unrelated to Crawlee, depend on the [`got-scraping`](https://www.npmjs.com/package/got-scraping) package directly instead.
@@ -0,0 +1,130 @@
1
+ ---
2
+ id: internals
3
+ title: 'Upgrading to v4: subclassing and internals'
4
+ sidebar_label: Subclassing and internals
5
+ sidebar_position: 1
6
+ slug: /upgrading/upgrading-to-v4/internals
7
+ ---
8
+
9
+ Skip this section unless you subclass Crawlee classes, override `protected` members, or read fields that were never documented. This page is part of the [Upgrading to v4](./upgrading-v4.md) guide.
10
+
11
+ ## Underscore prefix is removed from many protected and private methods
12
+
13
+ The leading underscore was dropped from protected and private class members across the codebase. The most visible rename is:
14
+
15
+ - `BasicCrawler._runRequestHandler` -> `BasicCrawler.runRequestHandler`
16
+
17
+ If you subclass a crawler or implement a custom browser plugin, these `protected` extension points lost their underscore too:
18
+
19
+ - `BasicCrawler._init` -> `init`
20
+ - `BasicCrawler._throwOnBlockedRequest` -> `throwOnBlockedRequest`
21
+ - `BasicCrawler._getMessageFromError` -> `getMessageFromError`
22
+ - `BasicCrawler._getCookieHeaderFromRequest` -> `getCookieHeaderFromRequest`
23
+ - `BrowserCrawler._navigationHandler` -> `navigationHandler` (including the `PlaywrightCrawler`, `PuppeteerCrawler` and `StagehandCrawler` overrides)
24
+ - `BrowserPlugin._addProxyToLaunchOptions` -> `addProxyToLaunchOptions`
25
+ - `BrowserPlugin._isChromiumBasedBrowser` -> `isChromiumBasedBrowser`
26
+ - `BrowserPlugin._throwAugmentedLaunchError` -> `throwAugmentedLaunchError`
27
+
28
+ The `@internal` `PlaywrightBrowser._setBrowserType` was renamed the same way, to `setBrowserType`.
29
+
30
+ A handful of hooks intentionally keep the underscore, because the un-prefixed name is taken by their public wrapper method: `BrowserPlugin._launch` (wrapped by `launch()`) and `BrowserController._close`, `_kill`, `_newPage`, `_getCookies`, `_setCookies` (wrapped by the same names without the underscore). Custom plugin or controller implementations override these under their existing names, unchanged.
31
+
32
+ Members that were also made `private` in the same pass are listed under [Unintentionally exposed internals are now private](#unintentionally-exposed-internals-are-now-private) below.
33
+
34
+ ## Private properties are native `#` fields now
35
+
36
+ Private class properties across the codebase were converted from TypeScript's compile-time `private` to native ECMAScript private fields (`#name`). Where a `private _foo` field backed a `get foo()` accessor, the field is now `#foo` — the public accessor is unchanged.
37
+
38
+ TypeScript's `private` was purely a compile-time construct: the properties still existed on the instances at runtime, so code could reach them via `(crawler as any).something` or `crawler['something']`, and they showed up in `Object.keys()`, object spread and `JSON.stringify()`. Native `#` fields close that hole — they are inaccessible outside the declaring class and invisible to enumeration and serialization. If you were reaching into any of them, that now fails at runtime, not just in the type checker. As with the visibility tightening above, the supported extension points (handlers, hooks, `ContextPipeline` composition and the `ISessionPool` / `IBrowserPool` / `IRequestManager` interfaces) are the way to go; open an issue if something you need is missing.
39
+
40
+ One related behavior change: `LaunchContext.extend()` now consistently rejects all declared fields as reserved keys — including `fingerprint` and `proxyUrl`, which previously slipped through the reserved-name check. Set those directly instead (e.g. `launchContext.fingerprint = ...`); `extend()` is only for attaching your own extra fields.
41
+
42
+ ## Unintentionally exposed internals are now private
43
+
44
+ A number of class members were `public` or `protected` only by accident — they were never meant to be part of the extension surface, are not used by any subclass, and in most cases also carried a leading underscore to signal that. In v4 they are `private` (and where it applies, `readonly`). If you were reaching into any of these — either to read internal state or to override a helper in a subclass — that no longer compiles.
45
+
46
+ This is intentional: these were never a supported API. If you relied on overriding one of the now-private helpers, the supported extension points (the `requestHandler`, `errorHandler`, `failedRequestHandler`, `preNavigationHooks`/`postNavigationHooks`, `ContextPipeline` composition, and the `ISessionPool` / `IBrowserPool` / `IRequestManager` interfaces) should cover the same use cases. If something you genuinely need is missing, open an issue.
47
+
48
+ The change spans, among others:
49
+
50
+ - **`BasicCrawler`** — `unexpectedStop`, `requestHandlerTimeoutMillis`, `sameDomainDelayMillis`, `domainAccessedTime`, `handledRequestsCount`, `statusMessageLoggingInterval`, `statusMessageCallback`, `ignoreHttpErrorStatusCodes`, `taskLoopOptions` (was `autoscaledPoolOptions`), `autoscaledPool`, `respectRobotsTxtFile`, and the helpers `buildBasicContextPipeline`, `validateRequestUserData`, `pauseOnMigration`, `fetchNextRequest`, `delayRequest`, `handleRequest`, `timeoutAndRetry`, `isTaskReadyFunction`, `defaultIsFinishedFunction`, `requestFunctionErrorHandler`, `handleFailedRequestHandler`, `canRequestBeRetried`
51
+ - **`HttpCrawler`** — `preNavigationHooks`, `postNavigationHooks`, `saveResponseCookies`, `navigationTimeoutMillis`, `suggestResponseEncoding`, `forceResponseEncoding`, `supportedMimeTypes`, and the helpers `requestFunction`, `parseResponse`, `getRequestOptions`, `encodeResponse`, `extendSupportedMimeTypes`, `handleRequestTimeout`
52
+ - **`AutoscaledPool`** — the whole class is `@internal` in v4, so its members are not enumerated here; see [`AutoscaledPool` is no longer public API](./autoscaling.md#autoscaledpool-is-no-longer-public-api)
53
+ - **`SessionPool`** — all pool internals (`log`, `maxPoolSize`, `createSessionFunction`, `keyValueStore`, `sessions`, `sessionMap`, `sessionOptions`, `persistStateKey`, `persistStateKeyValueStoreId`, `events`, `persistenceOptions`, `sessionReuseStrategy`, and the helpers `ensureInitialized`, `maybeLoadSessionPool`, `registerSession`, `createSession`, `hasSpaceForSession`, `pickSession`, `removeRetiredSessions`, `getRandomIndex`, `defaultCreateSessionFunction`)
54
+ - **`Session`** — `maybeSelfRetire` (`userData` is now `readonly`)
55
+ - **`RequestList`** — all `_`-prefixed helpers (`addFetchedRequests`, `addPersistedRequests`, `addRequest`, `addRequestsFromSources`, `ensureInProgress`, `ensureIsInitialized`, `ensureUniqueKeyValid`, `fetchRequestsFromUrl`, `getPersistedState`, `loadStateAndPersistedRequests`, `persistRequests`, `restoreState`)
56
+ - **`RequestQueue`** — `proxyConfiguration`, `requestCache`, `requestSeenCache`, `queuePausedForMigration`, `inProgressRequestBatchCount`, `expectedRequestProcessingSecs`, `httpClient`, `events`, and the helpers `cacheRequest`, `fetchRequestsFromUrl`, `addFetchedRequests` (`id`, `name`, `backend`, `log` are now `readonly`)
57
+ - **`ProxyConfiguration`** — `nextCustomUrlIndex`, `proxyUrls`, `newUrlFunction`, and the helpers `handleProxyUrlsList`, `callNewUrlFunction`, `throwCannotCombineCustomMethods`, `throwNoOptionsProvided` (the internal `log` field and `usedProxyUrls` map are removed; `isManInTheMiddle` is now `readonly`)
58
+ - **`Statistics`** — `saveRetryCountForRequest` (was `saveRetryCountForJob`), `teardown`, `keyValueStore` (`errorTracker`, `errorTrackerRetry` are now `readonly`, and `state` / `requestRetryHistogram` are getters)
59
+ - **`SystemStatus`** — `isSystemIdle`
60
+ - **`Router`** — the constructor is now `private`; use the static `Router.create()` factory
61
+ - **`BaseHttpClient`** — `log` (subclasses receive it via the constructor `logger` option instead of reading `this.log`)
62
+ - **`JSDOMCrawler`** — `runScripts`, `hideInternalConsole`, `virtualConsole`
63
+ - **`AdaptivePlaywrightCrawler`** — `commitResult`, `allowStorageAccess`, `enqueueLinks`
64
+ - **`RenderingTypePredictor`** — `calculateFeatureVector`, `retrain`
65
+ - **`BrowserCrawler`** — `navigationTimeoutMillis`, `preNavigationHooks`, `postNavigationHooks`, `saveResponseCookies` (now `private readonly`; configure them through the constructor options as before), and the helpers `isRequestBlocked`, `applyCookies` (was `_applyCookies`), `handleNavigationTimeout` (was `_handleNavigationTimeout`), `throwIfProxyError` (was `_throwIfProxyError`)
66
+ - **`BrowserLauncher`** — the helpers `getChromeExecutablePath`, `getTypicalChromeExecutablePath`, `validateProxyUrlProtocol` (were `_`-prefixed). `getDefaultHeadlessOption` (was `_getDefaultHeadlessOption`) stays `protected` — it is an override point (`PuppeteerLauncher` overrides it) — but lost its underscore prefix
67
+ - **`RobotsTxtFile.load` and `Sitemap.parse`** — internal static factory helpers, now `private` (use the public `RobotsTxtFile.from` / `Sitemap.load` / `Sitemap.fromXmlString` entry points)
68
+ - Various internal fields on `BrowserController` (`id`, `browserPlugin`) and `BrowserPlugin` (`name`, `library`, `launchOptions`, `proxyUrl`, `userDataDir`, `browserPerProxy`, `ignoreProxyCertificate`) are now `readonly` (the `log` field on both is off the public surface entirely — see [`BrowserPool` internals are private](./browser-management.md#browserpool-internals-are-private))
69
+
70
+ `BasicCrawler.running` remains public as a read-only getter indicating whether `run()` is in progress. Existing reads still work; assignments no longer do. The same goes for `hasFinishedBefore`: it is a public read-only getter now, and can no longer be assigned.
71
+
72
+ ## Declarations that are now `@internal`
73
+
74
+ These are still present at runtime, but they are excluded from the documented surface and can change without a major version bump: `Session.getState()`, `SessionOptions.log` and `RestrictedCrawlingContext.id`.
75
+
76
+ `BLOCKED_STATUS_CODES` is now typed `readonly number[]`. Copy it (`[...BLOCKED_STATUS_CODES]`) if you were mutating it.
77
+
78
+ ## `HttpCrawler.isRequestBlocked` is now private
79
+
80
+ Block detection is configured through `retryOnBlocked` and `blockedStatusCodes`; to add your own checks, throw a `SessionError` from a `postNavigationHook`.
81
+
82
+ ## The protected `getMessageFromError()` returns `string`
83
+
84
+ `BasicCrawler.getMessageFromError()` previously widened its return type to `string | TimeoutError | undefined`. Overrides must now return a `string`, and callers can drop any `as string` casts.
85
+
86
+ ## The `RequestQueue` constructor no longer takes a `Configuration`
87
+
88
+ The internal `RequestQueue` constructor dropped its second `config: Configuration` parameter (it also stopped exposing a `protected config` field). You should not be constructing `RequestQueue` directly anyway — use `RequestQueue.open()`, which resolves configuration for you.
89
+
90
+ ## Crawler generic parameters and handler types changed
91
+
92
+ To support the new `ContextPipeline` / `extendContext` composition, the crawler classes gained additional generic type parameters. `BasicCrawler<Context>` is now `BasicCrawler<Context, ContextExtension, ExtendedContext>`, and the same pattern was propagated to `HttpCrawler`, `CheerioCrawler`, `JSDOMCrawler`, `LinkeDOMCrawler`, `PuppeteerCrawler`, `PlaywrightCrawler`, `StagehandCrawler`, and their `*Options` interfaces. This only affects you if you **explicitly annotated** crawler generics or **subclassed** a crawler while narrowing its `Context` — in that case the compiler now expects the extra parameters (and a matching `contextPipelineBuilder`). Most users, who let the types be inferred, are unaffected.
93
+
94
+ The exported handler types were reshaped accordingly. `ErrorHandler` and `RequestHandler` no longer wrap their context in `LoadedContext<...>`; `ErrorHandler` now takes two type parameters (`ErrorHandler<BaseContext, ExtendedContext>`), receiving `inputs: BaseContext & Partial<ExtendedContext>`. The `LoadedContext` type is internal and no longer part of the public API; `RestrictedCrawlingContext` stays exported from `@crawlee/basic`. If you annotated handlers with `LoadedContext` directly, update the references; if you only used the crawler options' `requestHandler` / `errorHandler` / `failedRequestHandler` callbacks with inferred parameter types, nothing changes.
95
+
96
+ ## `Request` is split into `Request` and `CrawlingRequest`
97
+
98
+ `Request` in `@crawlee/core` is now just the stored record: URL, method, headers, payload, `userData`, `label` and the processing state a request queue keeps (`id`, `retryCount`, `errorMessages`, `handledAt`, `loadedUrl`). Everything a crawler reads off a request — `skipNavigation`, `crawlDepth`, `sessionId`, `maxRetries`, `state`, `pushErrorMessage()` — lives on `CrawlingRequest` in `@crawlee/basic`, which is what `request` is in every request handler and hook. `RequestState` moved along with it, so import it from `@crawlee/basic` (or `crawlee`), not `@crawlee/core`. Handler code is unaffected; the change only shows if you construct requests yourself or read them straight from a request manager:
99
+
100
+ - The options are unchanged: `new Request({ url, skipNavigation: true, maxRetries: 2 })` and `queue.addRequest({ url, sessionId })` still record the settings, they just are not readable as properties on the core class. Where you need them, `CrawlingRequest.fromSchema(request)` rebuilds the crawler view.
101
+ - `RequestOptions` no longer accepts `id` or `handledAt`, and the constructor ignores `retryCount`, `errorMessages` and `loadedUrl`. A request coming back from a storage is rebuilt with `Request.fromSchema(record)`, which is also what `RequestQueue` does internally.
102
+ - `RequestOptions.skippedReason` and `Request.skippedReason` are removed. They were an internal side-channel for reporting `maxCrawlDepth` skips out of a `transformRequestFunction`; the depth check no longer runs inside the transform, so nothing writes them.
103
+ - `crawlingContext.request` is never the object your request manager handed out — the crawler rebuilds it as a `CrawlingRequest`. With a `RequestQueue` that was already true (requests are rebuilt from the stored record on every fetch), and in v4 `RequestList` and `SitemapRequestLoader` feed the crawler through a queue too; the change is only observable with a custom `IRequestManager` whose `fetchNextRequest()` returned its own instances. The object passed back to `reclaimRequest()` / `markRequestAsHandled()` is the crawler's copy, so match on `uniqueKey` (or `id`), not by identity.
104
+
105
+ ## Navigation hook types are now generic
106
+
107
+ `PlaywrightHook`, `PuppeteerHook` and `StagehandHook` are now type aliases (previously interfaces) generic over the request's `userData` type. A hook that types its context — via the generic (e.g. `PlaywrightHook<MyUserData>`) or an explicit context annotation — is now assignable to the `preNavigationHooks` / `postNavigationHooks` options of an untyped crawler. If you extended one of these interfaces, use an intersection type instead.
108
+
109
+ ## Removed navigation hook type aliases
110
+
111
+ The `HttpHook`, `CheerioHook`, `JSDOMHook`, `LinkeDOMHook` and `FileDownloadHook` type aliases were removed. None of them could actually type a `preNavigationHooks` or `postNavigationHooks` entry: both options are typed over the *pre-navigation* crawling context, while these aliases closed over the fully parsed one — so a function annotated with them required the pre-navigation context to already supply `$`, `body` or `window`, and assignment was rejected. (`FileDownload` has no hook options at all.)
112
+
113
+ Let the hook be inferred from the options object, or annotate its parameter with the crawler's own context type:
114
+
115
+ ```diff
116
+ -const hook: CheerioHook = async (ctx) => { /* ... */ };
117
+ +const hook = async (ctx: CheerioCrawlingContext) => { /* ... */ };
118
+
119
+ new CheerioCrawler({ preNavigationHooks: [hook] });
120
+ ```
121
+
122
+ To type a standalone hook against the pre-navigation context, use `InternalHttpHook<CrawlingContext>`.
123
+
124
+ ## `RecoverableState` reshaped
125
+
126
+ `serialize` and `deserialize` now take and return values rather than strings (so v3 records will not load) and each also accept a [Standard Schema](https://standardschema.dev) — a zod codec works as `deserialize` directly — `reset()` is synchronous, no longer clears the persisted record (the new `resetStore()` does) and doubles as a way to establish the state without awaiting `initialize()`, `persistStateKvsName` and `persistStateKvsId` collapsed into a single `keyValueStore` option taking a store (or a pending `KeyValueStore.open()`), `defaultState` also accepts a factory (which you need for a state `structuredClone` cannot rebuild, as the deep copy no longer goes through `serialize`/`deserialize`), and there is a new `persistenceTimeoutMillis` option. `teardown()` is no longer terminal — `initialize()` can be called again to open another persistence window — and a write that fails during a periodic `PERSIST_STATE` or during `teardown()` is warned about rather than thrown. A direct `persistState()` still throws.
127
+
128
+ ## The `log` property is typed as `CrawleeLogger`
129
+
130
+ The `log` property exposed throughout the public API (on the crawling context, the crawler, `RequestQueue`, etc.) is now typed as the `CrawleeLogger` interface (from `@crawlee/types`) rather than the concrete `Log` class from `@apify/log`. If you consume it structurally — calling `log.info(...)`, `log.debug(...)`, `log.child(...)` — nothing changes. You only need to act if you explicitly annotated a variable or parameter with the `Log` type from `@apify/log` and assigned `context.log` to it; type it as `CrawleeLogger` instead.
@@ -0,0 +1,63 @@
1
+ ---
2
+ id: removed-symbols
3
+ title: 'Upgrading to v4: removed symbols'
4
+ sidebar_label: Removed symbols
5
+ sidebar_position: 10
6
+ slug: /upgrading/upgrading-to-v4/removed-symbols
7
+ ---
8
+
9
+ The full list of removed exports and members, for ctrl-F purposes. Where a replacement exists, it is noted inline. This page is part of the [Upgrading to v4](./upgrading-v4.md) guide.
10
+
11
+ ## Removed symbols
12
+
13
+ - `BasicCrawler._cleanupContext` (protected) - this is now handled by the `ContextPipeline`
14
+ - `BasicCrawler.isRequestBlocked` (protected)
15
+ - `BasicCrawler.events` (protected) - use the `serviceLocator` export of `@crawlee/core` instead (`serviceLocator.getEventManager()`); the crawler scopes it to its own services while its methods run
16
+ - `BrowserRequestHandler` and `BrowserErrorHandler` types in `@crawlee/browser`
17
+ - `BrowserCrawler.userProvidedRequestHandler` (protected)
18
+ - `BrowserCrawler.requestHandlerTimeoutInnerMillis` (protected)
19
+ - `BrowserCrawler._enhanceCrawlingContextWithPageInfo` (protected)
20
+ - `BrowserCrawler._handleNavigation` (protected)
21
+ - `HttpCrawler.userRequestHandlerTimeoutMillis` (protected)
22
+ - `HttpCrawler._handleNavigation` (protected)
23
+ - `HttpCrawler._applyCookies` (protected) - cookie merging is now handled by `BaseHttpClient`
24
+ - `HttpCrawler._parseHTML` (protected)
25
+ - `HttpCrawler.use` and the `CrawlerExtension` class (experimental) - the `ContextPipeline` should be used for extending the crawler
26
+ - `BasicCrawler._tagUserHandlerError` (protected) - internal error-tagging helper, no longer part of the crawler surface
27
+ - `BasicCrawler.handledRequestsCount` setter (`@deprecated`) - the throw-on-assign guard is gone; the getter is now internal-only and the count is derived from `this.statistics`
28
+ - `PlaywrightPlugin._containerProxyServer` (public) - was only populated with `experimentalContainers`, and is removed together with that option
29
+ - `Snapshotter._snapshotMemory`, `Snapshotter._memoryOverloadWarning`, `Snapshotter._snapshotEventLoop`, `Snapshotter._snapshotCpu`, `Snapshotter._snapshotClient`, `Snapshotter._pruneSnapshots` (all `@deprecated` protected stubs) - snapshotting is now handled by the individual load signals, and the `Snapshotter` itself is internal to `ConcurrencySystem`; there is no longer a public API for reading raw resource snapshots
30
+ - `FileDownloadOptions.streamHandler` - streaming should now be handled directly in the `requestHandler` instead
31
+ - `playwrightUtils.registerUtilsToContext` and `puppeteerUtils.registerUtilsToContext` - this is now added to the context via `ContextPipeline` composition
32
+ - `context.blockResources` and `context.cacheResponses`, and the `puppeteerUtils.blockResources` / `puppeteerUtils.cacheResponses` functions behind them — both had a severe performance cost in recent Puppeteer versions and were already deprecated. Use `puppeteerUtils.blockRequests(page, options)`, which blocks URL patterns over CDP without disabling the browser cache. If you were caching responses, rely on the in-browser cache instead.
33
+ - `context.closeCookieModals`, `playwrightUtils.closeCookieModals` and `puppeteerUtils.closeCookieModals` — removed along with the optional `idcac-playwright` peer dependency (see [Crawling context no longer includes `closeCookieModals`](./upgrading-v4.md#crawling-context-no-longer-includes-closecookiemodals) and the [cookie modals guide](https://crawlee.dev/js/docs/next/guides/cookie-modals))
34
+ - `Configuration.systemInfoV2` / `CRAWLEE_SYSTEM_INFO_V2` environment variable — the v2 behavior is now the default (see [Available resource detection](./utils-and-types.md#available-resource-detection))
35
+ - `KeyValueStore.getInput()` and `Configuration.inputKey` / `CRAWLEE_INPUT_KEY` — reading the run input moved to the Apify SDK (see [`KeyValueStore.getInput()` and `Configuration.inputKey` moved to the Apify SDK](./upgrading-v4.md#keyvaluestoregetinput-and-configurationinputkey-moved-to-the-apify-sdk))
36
+ - `Configuration.defaultDatasetId` / `defaultKeyValueStoreId` / `defaultRequestQueueId` and their `CRAWLEE_DEFAULT_*_ID` environment variables — the default storage is addressed by a reserved alias, not by a configurable ID. Open a storage by name if you need a specific one.
37
+ - `checkAndSerialize` and `chunkBySize` functions (from `@crawlee/core`) — internal helpers of `Dataset.pushData()` (JSON-serializability and size checks, batching); there is no public replacement
38
+ - `BASIC_CRAWLER_TIMEOUT_BUFFER_SECS` constant (from `@crawlee/basic`) — was an internal timeout buffer, no longer exported
39
+ - `HttpResponse`, `StreamingHttpResponse`, `ResponseTypes`, `BaseHttpResponseData`, and `GotScrapingHttpClient` (from `@crawlee/core`) — the HTTP client surface moved to `@crawlee/http-client` / `@crawlee/got-scraping-client` (see [HTTP client packages and `BaseHttpClient` reshaped](./http-clients.md#http-client-packages-and-basehttpclient-reshaped))
40
+ - `StreamHandlerContext` type (from `@crawlee/http`); `FileDownloadOptions` stays but only adds `ignoreTlsErrors` on top of `BasicCrawlerOptions` — see [`FileDownload` now extends `BasicCrawler`](./upgrading-v4.md#filedownload-now-extends-basiccrawler-and-takes-a-slimmer-filedownloadoptions)
41
+ - `PlainResponse` type (from `@crawlee/http`) — it wrapped the `got-scraping` response and is gone along with the rest of the old HTTP response surface (see [`CrawlingContext.response` is now of type `Response`](./upgrading-v4.md#crawlingcontextresponse-is-now-of-type-response))
42
+ - `checkStorageAccess`, `withCheckedStorageAccess` and the `RequestHandlerResult` type — superseded by the storage transaction mechanism; use `withDirectStorageAccess()` and `StorageTransactionView` (see [Storage writes in request handlers are transactional](./upgrading-v4.md#storage-writes-in-request-handlers-are-transactional))
43
+ - `CreateContextOptions` type (from `@crawlee/basic`) — a leftover of the pre-`ContextPipeline` context-creation design, unused by the library itself; context construction is now driven by `ContextPipeline`
44
+ - `ResponseLike` interface (from `@crawlee/core`) — a vestige of the pre-`fetch` HTTP implementation; `getCookiesFromResponse()`, which took it in v3, now takes a native `Response`
45
+ - The standalone `enqueueLinks()` function (from `@crawlee/core`) — use `context.enqueueLinks()` inside a request handler, or `context.addRequests()` / `crawler.addRequests()` for URLs you already have
46
+ - `UrlPatternObject` (from `@crawlee/core`) — the *compiled* form of a URL pattern, produced internally by the `enqueueLinks()` machinery. Use `UrlPatternInput` (new in v4) / `GlobInput` / `RegExpInput` for the patterns you pass in, and let the return type of the pattern helpers be inferred
47
+ - `createCpuLoadSignal()`, `createEventLoopLoadSignal()`, `createClientLoadSignal()` and the `ClientLoadSignal` / `ClientLoadSignalOptions` / `ClientSnapshot` types (from `@crawlee/core`) — construct `CpuLoadSignal`, `EventLoopLoadSignal` or `StorageBackendLoadSignal` instead (see [Load-signal options restructured](./autoscaling.md#load-signal-options-restructured))
48
+ - `StorageClient.setStatusMessage()` — status messages are broadcast as an `EventType.STATUS_MESSAGE` event (see [`StorageBackend` interface simplified](./storage-backends.md#storagebackend-interface-simplified))
49
+ - `chunk()`, `weightedAvg()`, `snakeCaseToCamelCase()`, `snapshotPageWithIframes()`, `entries()` and `keys()` (from `@crawlee/utils`) — see [Removed and relocated `@crawlee/utils` exports](./utils-and-types.md#removed-and-relocated-crawleeutils-exports)
50
+ - `PERSIST_STATE_KEY` (from `@crawlee/core`) — to change where a session pool persists its state, pass `persistStateKey` to `SessionPool`
51
+ - `MAX_POOL_SIZE` constant (from `@crawlee/core`) — was the internal default for `SessionPoolOptions.maxPoolSize` (1000); inline the literal if you were reading it
52
+ - `WithRequired` type (from `@crawlee/core`) — a bare TypeScript utility that was never crawlee vocabulary; `LoadedRequest` no longer goes through it, so declare your own if you were using it
53
+ - `ErrorSnapshotter` and its `SnapshotResult` return type (from `@crawlee/core`) — an implementation detail of `ErrorTracker`. Error snapshotting is opt-in through `new Statistics({ saveErrorSnapshots: true })` (or `new ErrorTracker({ saveErrorSnapshots: true })`)
54
+ - `ErrorTracker.errorSnapshotter` and `ErrorTracker.captureSnapshot()` — both private now. Snapshotting is driven from `addAsync()` on the first occurrence of each distinct error; the captured URLs surface as `firstErrorScreenshotUrl` / `firstErrorHtmlUrl` on the corresponding node of `errorTracker.result`, as before
55
+ - `MinimumSpeedStream` and `ByteCounterStream` (from `@crawlee/http`) — these `Transform` factories existed only to be piped inside `FileDownloadOptions.streamHandler`, which v4 removed. Compose your own `Transform` around `context.response.body` in the `requestHandler` instead; see the [file download with streams example](https://crawlee.dev/js/docs/examples/file-download-stream)
56
+ - `HttpHook`, `FileDownloadHook`, `CheerioHook`, `JSDOMHook` and `LinkeDOMHook` types — see [Removed navigation hook type aliases](./internals.md#removed-navigation-hook-type-aliases)
57
+ - The `puppeteerClickElements` namespace (from `@crawlee/puppeteer`) — `clickElements`, `clickElementsAndInterceptNavigationRequests` and `isTargetRelevant` were internal helpers. Use `puppeteerUtils.enqueueLinksByClickingElements()`, or `context.enqueueLinksByClickingElements()` inside a request handler; the `EnqueueLinksByClickingElementsOptions` type is still exported directly from `@crawlee/puppeteer`
58
+ - The `puppeteerRequestInterception` namespace (from `@crawlee/puppeteer`) — it only duplicated `puppeteerUtils.addInterceptRequestHandler` / `puppeteerUtils.removeInterceptRequestHandler`, which are unchanged. The `InterceptHandler` type is still exported directly from `@crawlee/puppeteer`
59
+ - The top-level type exports `BlockRequestsOptions`, `InjectFileOptions`, `InfiniteScrollOptions`, `SaveSnapshotOptions`, `CompiledScriptParams` and `CompiledScriptFunction` (from `@crawlee/puppeteer`) — the types themselves are unchanged and remain reachable through the namespace, e.g. `import { puppeteerUtils } from 'crawlee'; let options: puppeteerUtils.SaveSnapshotOptions;`. This matches `@crawlee/playwright`, which never exported them at the top level. `PuppeteerDirectNavigationOptions` is unaffected
60
+
61
+ ### The protected `BasicCrawler.crawlingContexts` map is removed
62
+
63
+ The property was not used by the library itself and re-implementing the functionality in user code is fairly straightforward.