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): allow unsetting launch context proxy URL (#3621)

Adarsh Tiwarid5ab219ec652
diff --git a/packages/browser-pool/src/launch-context.ts b/packages/browser-pool/src/launch-context.ts
index 669d78937..d2bf4bc28 100644
--- a/packages/browser-pool/src/launch-context.ts
+++ b/packages/browser-pool/src/launch-context.ts
@@ -138,6 +138,7 @@ export class LaunchContext<
*/
set proxyUrl(url: string | undefined) {
if (!url) {
+ this._proxyUrl = undefined;
return;
}
diff --git a/test/browser-pool/browser-plugins/plugins.test.ts b/test/browser-pool/browser-plugins/plugins.test.ts
index 468dd7074..e4bef283c 100644
--- a/test/browser-pool/browser-plugins/plugins.test.ts
+++ b/test/browser-pool/browser-plugins/plugins.test.ts
@@ -112,6 +112,17 @@ const runPluginTest = <
expect(context.userDataDir).toEqual('test');
});
+ test.concurrent('should allow unsetting launchContext proxyUrl', () => {
+ const plugin = new Plugin(library as never);
+ const context = plugin.createLaunchContext();
+
+ context.proxyUrl = 'http://proxy.com/';
+ expect(context.proxyUrl).toEqual('http://proxy.com');
+
+ context.proxyUrl = undefined;
+ expect(context.proxyUrl).toBeUndefined();
+ });
+
test.concurrent('should create browser controller', () => {
const plugin = new Plugin(library as never);
const browserController = plugin.createController();