-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #457 from angrykoala/dev
2.12.1
- Loading branch information
Showing
4 changed files
with
41 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import puppeteer from 'puppeteer'; | ||
import { FinalBrowserSettings } from '../types'; | ||
import PuppeteerContext from './puppeteer_context'; | ||
import { BrowserContext } from './puppeteer_types'; | ||
export class PuppeteerLauncher { | ||
|
||
public async launch(settings: FinalBrowserSettings): Promise<PuppeteerContext> { | ||
let instance; | ||
try { | ||
instance = await puppeteer.launch(settings); | ||
} catch (err) { | ||
// retry to avoid one-off _dl_allocate_tls_init error | ||
instance = await puppeteer.launch(settings); | ||
} | ||
let context: BrowserContext; | ||
if (settings.incognito) { | ||
context = await instance.createIncognitoBrowserContext(); | ||
} else context = instance.defaultBrowserContext(); | ||
|
||
return new PuppeteerContext(context); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters