Skip to content

Crawlee—A web scraping and browser automation library for Node.js to build reliable crawlers. In JavaScript and TypeScript. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Puppeteer, Playwright, Cheerio, JSDOM, and raw HTTP. Both headful and headless mode. With proxy rotation.

fix(browser-pool): respect user options before assigning fingerpints (#2190)

Sviatozar Petrenkof050776a916a
diff --git a/packages/browser-pool/src/fingerprinting/hooks.ts b/packages/browser-pool/src/fingerprinting/hooks.ts
index 662d6f1a9..e7c74711d 100644
--- a/packages/browser-pool/src/fingerprinting/hooks.ts
+++ b/packages/browser-pool/src/fingerprinting/hooks.ts
@@ -63,8 +63,8 @@ export function createPrePageCreateHook() {
const { fingerprint } = launchContext.fingerprint!;
if (launchContext.useIncognitoPages && browserPlugin instanceof PlaywrightPlugin && pageOptions) {
- pageOptions.userAgent = fingerprint.navigator.userAgent;
- pageOptions.viewport = {
+ pageOptions.userAgent ??= fingerprint.navigator.userAgent;
+ pageOptions.viewport ??= {
width: fingerprint.screen.width,
height: fingerprint.screen.height,
};
diff --git a/packages/browser-pool/src/utils.ts b/packages/browser-pool/src/utils.ts
index 70d722760..1130302bb 100644
--- a/packages/browser-pool/src/utils.ts
+++ b/packages/browser-pool/src/utils.ts
@@ -35,7 +35,7 @@ export type InferBrowserPluginArray<
// Return the results
? Result
// If the input is a general array of elements (not a tuple), infer it's values type
- : Input extends (infer U)[]
+ : Input extends readonly (infer U)[]
// If the values are a union of the plugins
? [U] extends [PuppeteerPlugin | PlaywrightPlugin]
// Return an array of the union