Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: respect headless option in browser crawlers #1455

Merged
merged 1 commit into from
Aug 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/browser-crawler/src/internals/browser-crawler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ export abstract class BrowserCrawler<
postNavigationHooks: ow.optional.array,

launchContext: ow.optional.object,
headless: ow.optional.boolean,
browserPoolOptions: ow.object,
sessionPoolOptions: ow.optional.object,
persistCookiesPerSession: ow.optional.boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ export class PlaywrightCrawler extends BrowserCrawler<{ browserPlugins: [Playwri

const {
launchContext = {},
headless,
browserPoolOptions = {} as BrowserPoolOptions<PlaywrightPlugin>,
...browserCrawlerOptions
} = options;
Expand All @@ -199,6 +200,11 @@ export class PlaywrightCrawler extends BrowserCrawler<{ browserPlugins: [Playwri
+ 'Use PlaywrightCrawlerOptions.proxyConfiguration');
}

if (headless != null) {
launchContext.launchOptions ??= {} as LaunchOptions;
launchContext.launchOptions.headless = headless;
}

const playwrightLauncher = new PlaywrightLauncher(launchContext, config);

browserPoolOptions.browserPlugins = [
Expand Down
6 changes: 6 additions & 0 deletions packages/puppeteer-crawler/src/internals/puppeteer-crawler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export class PuppeteerCrawler extends BrowserCrawler<{ browserPlugins: [Puppetee

const {
launchContext = {},
headless,
browserPoolOptions = {} as BrowserPoolOptions,
proxyConfiguration,
...browserCrawlerOptions
Expand All @@ -150,6 +151,11 @@ export class PuppeteerCrawler extends BrowserCrawler<{ browserPlugins: [Puppetee
+ 'Use PuppeteerCrawlerOptions.proxyConfiguration');
}

if (headless != null) {
launchContext.launchOptions ??= {} as LaunchOptions;
launchContext.launchOptions.headless = headless;
}

const puppeteerLauncher = new PuppeteerLauncher(launchContext, config);

browserPoolOptions.browserPlugins = [
Expand Down