close browser when request finished
This commit is contained in:
@ -16,7 +16,7 @@ app.get('/', (req, res) => {
|
||||
res.send(403)
|
||||
return
|
||||
}
|
||||
fetchContent(req, res)
|
||||
return fetchContent(req, res)
|
||||
});
|
||||
|
||||
app.post('/', (req, res) => {
|
||||
@ -25,7 +25,7 @@ app.post('/', (req, res) => {
|
||||
res.send(403)
|
||||
return
|
||||
}
|
||||
fetchContent(req, res)
|
||||
return fetchContent(req, res)
|
||||
});
|
||||
|
||||
const PORT = parseInt(process.env.PORT) || 8080;
|
||||
@ -34,4 +34,4 @@ app.listen(PORT, () => {
|
||||
console.log('Press Ctrl+C to quit.');
|
||||
});
|
||||
|
||||
module.exports = app;
|
||||
module.exports = app;
|
||||
|
||||
@ -380,7 +380,7 @@ async function fetchContent(req, res) {
|
||||
console.log(`parse-page`, logRecord);
|
||||
} finally {
|
||||
if (context) {
|
||||
await context.close();
|
||||
await context.browser().close();
|
||||
}
|
||||
}
|
||||
|
||||
@ -552,7 +552,7 @@ async function retrievePage(url) {
|
||||
if (lastPdfUrl) {
|
||||
return { context, page, finalUrl: lastPdfUrl, contentType: 'application/pdf' };
|
||||
}
|
||||
await context.close();
|
||||
await browser.close();
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user