Skip to content

Commit

Permalink
feat: add timeout support (#733)
Browse files Browse the repository at this point in the history
  • Loading branch information
itairaz1 authored Nov 3, 2022
1 parent 40efeee commit 4dc3e69
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/scrapers/base-scraper-with-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ class BaseScraperWithBrowser extends BaseScraper {
} else {
const executablePath = this.options.executablePath || undefined;
const args = this.options.args || [];
const { timeout } = this.options;

const headless = !this.options.showBrowser;
debug(`launch a browser with headless mode = ${headless}`);
Expand All @@ -146,6 +147,7 @@ class BaseScraperWithBrowser extends BaseScraper {
headless,
executablePath,
args,
timeout,
});
}

Expand Down
6 changes: 6 additions & 0 deletions src/scrapers/base-scraper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ export interface ScraperOptions {
*/
args?: string[];

/**
* Maximum navigation time in milliseconds, pass 0 to disable timeout.
* @default 30000
*/
timeout?: number | undefined;

/**
* adjust the browser instance before it is being used
*
Expand Down

0 comments on commit 4dc3e69

Please sign in to comment.