|
|
@ -369,7 +369,8 @@ class Driver {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async init() {
|
|
|
|
async init() {
|
|
|
|
this.log('Launching browser...')
|
|
|
|
for (let attempt = 1; attempt <= 3; attempt++) {
|
|
|
|
|
|
|
|
this.log(`Launching browser (attempt ${attempt})...`)
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (CHROMIUM_WEBSOCKET) {
|
|
|
|
if (CHROMIUM_WEBSOCKET) {
|
|
|
@ -384,9 +385,20 @@ class Driver {
|
|
|
|
acceptInsecureCerts: true,
|
|
|
|
acceptInsecureCerts: true,
|
|
|
|
args: chromiumArgs,
|
|
|
|
args: chromiumArgs,
|
|
|
|
executablePath: CHROMIUM_BIN,
|
|
|
|
executablePath: CHROMIUM_BIN,
|
|
|
|
|
|
|
|
timeout: 5000,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
|
|
this.log(error)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (attempt >= 3) {
|
|
|
|
|
|
|
|
throw new Error(error.message || error.toString())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.browser.on('disconnected', async () => {
|
|
|
|
this.browser.on('disconnected', async () => {
|
|
|
|
this.log('Browser disconnected')
|
|
|
|
this.log('Browser disconnected')
|
|
|
|
|
|
|
|
|
|
|
@ -398,11 +410,6 @@ class Driver {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
} catch (error) {
|
|
|
|
|
|
|
|
this.log(error)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
throw new Error(error.message || error.toString())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async destroy() {
|
|
|
|
async destroy() {
|
|
|
@ -537,7 +544,7 @@ class Site {
|
|
|
|
promise,
|
|
|
|
promise,
|
|
|
|
fallback,
|
|
|
|
fallback,
|
|
|
|
errorMessage = 'Operation took too long to complete',
|
|
|
|
errorMessage = 'Operation took too long to complete',
|
|
|
|
maxWait = Math.min(this.options.maxWait, 1000)
|
|
|
|
maxWait = Math.min(this.options.maxWait, 3000)
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
let timeout = null
|
|
|
|
let timeout = null
|
|
|
|
|
|
|
|
|
|
|
@ -1260,7 +1267,7 @@ class Site {
|
|
|
|
|
|
|
|
|
|
|
|
const body = await get(new URL(path, url.href), {
|
|
|
|
const body = await get(new URL(path, url.href), {
|
|
|
|
userAgent: this.options.userAgent,
|
|
|
|
userAgent: this.options.userAgent,
|
|
|
|
timeout: Math.min(this.options.maxWait, 1000),
|
|
|
|
timeout: Math.min(this.options.maxWait, 3000),
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
this.log(`Probe ok (${path})`)
|
|
|
|
this.log(`Probe ok (${path})`)
|
|
|
|