Skip to content
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

fix(🐛): Handle page and snapshot errors #562

Merged
merged 1 commit into from
Sep 9, 2020

Conversation

wwilsman
Copy link
Contributor

@wwilsman wwilsman commented Sep 9, 2020

Purpose

Sometimes, due to various reasons, the running browser might disconnect from Puppeteer during asset discovery causing a target closed error. This error can happen anytime CDP sends a message to the browser, such as enabling JS or setting viewport options. Since it is unhandled it can result in the local server being unable to respond to requests which can then result in request timeouts.

Approach

Within asset discovery, move any interaction with the page object into an error handler. The various request event registrations do not have to be protected since they are generic event emitter registration methods.

I also noticed that none of the methods within the snapshot handler were protected, which might contribute to the server hanging since it does not respond for unhandled async errors by default. I wrapped the snapshot method with another try-catch to help ensure that the server responds when an error is encountered.

Sometimes, due to various reasons, the running browser might disconnect from Puppeteer during asset
discovery causing a `target closed` error. This error can happen anytime CDP sends a message to the
browser, such as enabling JS or setting viewport options. Since it is unhandled it can result in the
local server being unable to respond to requests which can then result in request timeouts.
Copy link
Contributor

@Robdel12 Robdel12 left a comment

Choose a reason for hiding this comment

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

🏁 LGTM (much needed, I think we can assume none of the promises are caught)

@wwilsman wwilsman merged commit 29dad28 into master Sep 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants