dsfdsf
This commit is contained in:
5
index.js
5
index.js
@@ -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 {
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user