-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No need to await for the browser to be closed to send back the screenshot #653
Conversation
…shot Awaiting for the headless browser to be closed add a certain amount of time to the duration of the request, although the image is already ready to be sent back to the user.
Thanks! |
1 similar comment
Thanks! |
Codecov Report
@@ Coverage Diff @@
## master #653 +/- ##
=======================================
Coverage 48.52% 48.52%
=======================================
Files 1 1
Lines 68 68
=======================================
Hits 33 33
Misses 35 35 Continue to review full report at Codecov.
|
@@ -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(); |
There was a problem hiding this comment.
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
🤖 I have created a release \*beep\* \*boop\* --- ### [3.1.1](https://www.github.com/googleapis/nodejs-dialogflow/compare/v3.1.0...v3.1.1) (2020-07-23) ### Bug Fixes * publish missing client config annotations ([#653](https://www.github.com/googleapis/nodejs-dialogflow/issues/653)) ([b368797](https://www.github.com/googleapis/nodejs-dialogflow/commit/b36879723fd3aeab0c158d3ab76a5aa6505498e1)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please).
🤖 I have created a release \*beep\* \*boop\* --- ### [3.1.1](https://www.github.com/googleapis/nodejs-dialogflow/compare/v3.1.0...v3.1.1) (2020-07-23) ### Bug Fixes * publish missing client config annotations ([#653](https://www.github.com/googleapis/nodejs-dialogflow/issues/653)) ([b368797](https://www.github.com/googleapis/nodejs-dialogflow/commit/b36879723fd3aeab0c158d3ab76a5aa6505498e1)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please).
🤖 I have created a release \*beep\* \*boop\* --- ### [3.1.1](https://www.github.com/googleapis/nodejs-dialogflow/compare/v3.1.0...v3.1.1) (2020-07-23) ### Bug Fixes * publish missing client config annotations ([#653](https://www.github.com/googleapis/nodejs-dialogflow/issues/653)) ([b368797](https://www.github.com/googleapis/nodejs-dialogflow/commit/b36879723fd3aeab0c158d3ab76a5aa6505498e1)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please).
Awaiting for the headless browser to be closed add a certain amount of time to the duration of the request, although the image is already ready to be sent back to the user.
/cc @steren