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

Catch unhandled Browsershot exceptions in crawlFailed #469

Merged
merged 6 commits into from
Jul 31, 2024

Conversation

superpenguin612
Copy link
Contributor

Fixes #324.

I ran into this issue myself, and it ended up crashing the crawler prematurely. This PR catches any ProcessFailedExceptions on the Browsershot method, and sends it to observers via crawlFailed. I also included a test that loads a URL that never goes to network idle, triggering the 30s network timeout from Puppeteer. Originally, this creates an exception, but now it is caught appropriately.

One note here is that exceptions like Puppeteer not finding a Chrome binary are no longer displayed to the user by default, they would need to see the exception in crawlFailed. I'm not sure if there is a way to "fix" that, but that in theory should be what happens, anyway.

Feel free to ask to use a different method of testing this; this test takes 30s to execute which may be undesirable (maybe use Browsershot's waitForFunction to get the 5s timeout, like what @kmcluckie posted)?

@superpenguin612 superpenguin612 changed the title Catch unhandled Browsershot exceptions in crawlFailed. Catch unhandled Browsershot exceptions in crawlFailed Jul 29, 2024
@freekmurze freekmurze merged commit 099ea77 into spatie:main Jul 31, 2024
10 checks passed
@freekmurze
Copy link
Member

Thanks!

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.

Browsershot exceptions unhandled
2 participants