This commit is contained in:
spiduler
2020-10-21 23:41:56 +09:00
parent e8615cc26e
commit 7c604ed2a0
2 changed files with 12 additions and 5 deletions

View File

@@ -63,7 +63,10 @@ process.on('SIGTERM', exitHandler.bind(null, { cleanup: true }));
* request handler * request handler
*/ */
app.post('/', async (req, res, next) => { app.post('/', async (req, res, next) => {
browser.get(req.body).then(html => res.send(html)).catch(e => { browser.get(req.body).then(html => {
if (html) res.send(html)
else throw new Error('Emtpy html')
}).catch(e => {
if (e instanceof NoSuchSessionError) { if (e instanceof NoSuchSessionError) {
logger.error({ reason: e.message, url: req.url }, 'Browser session expired') logger.error({ reason: e.message, url: req.url }, 'Browser session expired')
} else { } else {

View File

@@ -112,6 +112,10 @@ class SeleniumBrowser {
.then(html => { .then(html => {
this.pool.release(driver) this.pool.release(driver)
return html return html
}).catch(err => {
logger.error({message: err.message}, 'Wait element failed')
this.pool.release(driver)
return ''
}) })
} else { } else {
this.pool.release(driver) this.pool.release(driver)