Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion appengine/headless-chrome/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ app.use(async (req, res) => {
const page = await browser.newPage();
await page.goto(url);
const imageBuffer = await page.screenshot();
await browser.close();
browser.close();
Copy link
Contributor

@MylesBorins MylesBorins Jun 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it have made more sense to put the res.set & res.send calls before await browser.close? Keeping the await ensured that the browser session was closed without error before the route was finished.

Albeit there is no error handling in this example, so any throw would cause an unhandled exception error, but it does seem odd to me to have this async operation continue doing it's thing after the function has returned


res.set('Content-Type', 'image/png');
res.send(imageBuffer);
Expand Down