destroy session for all error
This commit is contained in:
6
index.js
6
index.js
@@ -66,11 +66,7 @@ process.on('SIGTERM', exitHandler.bind(null, { cleanup: true }));
|
||||
*/
|
||||
app.post('/', async (req, res, next) => {
|
||||
browser.get(req.body).then(html => res.send(html)).catch(e => {
|
||||
if (e instanceof NoSuchSessionError) {
|
||||
logger.error({ reason: e.message, url: req.url }, 'Browser session expired')
|
||||
} else {
|
||||
logger.error(Object.assign({ message: e.message }, { info: e.info }), 'Browser error occured')
|
||||
}
|
||||
logger.error({ message: e.message, info: e.info }, 'Browser error')
|
||||
res.status(500).send({ code: 500, message: e.message })
|
||||
})
|
||||
})
|
||||
|
||||
@@ -21,10 +21,8 @@ class SeleniumBrowser {
|
||||
.then(() => driver.findElement(By.css('body')))
|
||||
.then(body => body.getAttribute('innerHTML'))
|
||||
.catch(e => {
|
||||
if (e instanceof NoSuchSessionError) {
|
||||
this.pool.destroy(driver)
|
||||
throw new NoSuchSessionError
|
||||
}
|
||||
throw new Error(e.message)
|
||||
})
|
||||
let p = captcha.isCaptchaPage(html) ? captcha.resolveCaptcha(driver, this.pool) : this.getHtml(driver, html, params)
|
||||
html = await p
|
||||
|
||||
Reference in New Issue
Block a user