File tree 1 file changed +15
-3
lines changed
1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,7 @@ export async function create(puppeteerArgs) {
78
78
79
79
// Create a browser
80
80
if ( ! browser ) {
81
+ const maxTries = 25 ;
81
82
let tryCount = 0 ;
82
83
83
84
const open = async ( ) => {
@@ -88,18 +89,29 @@ export async function create(puppeteerArgs) {
88
89
) ;
89
90
browser = await puppeteer . launch ( launchOptions ) ;
90
91
} catch ( error ) {
92
+ // This isn't a full error yet as puppeteer sometimes takes time to
93
+ // initialize properly.
91
94
logWithStack (
92
- 1 ,
95
+ 2 ,
93
96
error ,
94
- ' [browser] Failed to launch a browser instance.'
97
+ ` [browser] Failed to launch a browser instance - retrying (attempt ${ tryCount } / ${ maxTries } ).`
95
98
) ;
96
99
97
100
// Retry to launch browser until reaching max attempts
98
101
if ( tryCount < 25 ) {
99
- log ( 3 , `[browser] Retry to open a browser (${ tryCount } out of 25).` ) ;
102
+ log (
103
+ 3 ,
104
+ `[browser] Retry to open a browser (attempt ${ tryCount } /${ maxTries } ).`
105
+ ) ;
100
106
await new Promise ( ( response ) => setTimeout ( response , 4000 ) ) ;
101
107
await open ( ) ;
102
108
} else {
109
+ //... now it's an error
110
+ logWithStack (
111
+ 1 ,
112
+ error ,
113
+ '[browser] Failed to load browser after maximum retries reached.'
114
+ ) ;
103
115
throw error ;
104
116
}
105
117
}
You can’t perform that action at this time.
0 commit comments