-
-
Notifications
You must be signed in to change notification settings - Fork 136
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
Detect non-2XX response from website #89
Comments
That's what I'm doing and it works on other websites: Lines 229 to 232 in 808757d
|
It's possible to detect the status code. I haven't made up my mind whether it makes sense to throw on non-200 response by default or not.
https://pptr.dev/#?product=Puppeteer&version=v10.0.0&show=api-pagegotourl-options |
Thanks for your suggestions and getting back to me.
Interestingly, it worked for me too (including on your website), just not on Google News for some reason. I'll experiment a bit more and let you know if I discover any reason for it.
If you wanted to keep it simple, what about a certain number of retries (e.g., 3) on non-2XX response? Or, even an option to throw errors on non-2XX response (false by default) -- or finally -- what about returning this code as the ultimate returned response from the promise? I think it makes sense - especially in the context of website screenshots - to detect the response code. |
You could add retried, I think it would be even nicer to return the status code and leave it up to the programmer to decide what to do (in my case, a non-200 indicates a serious failure, and I don't want to take a screenshot, I want to know that it failed and throw away the screenshot). - Also thanks for the fantastic module! |
Thanks for writing this great plugin. Is there any way to detect/retry errors from non-2XX responses in the screenshots?
For example:
I am using:
await captureWebsite.file(url, filename, options)
Also, unrelated, but setting
darkMode: true
doesn't seem to work forhttps://news.google.com
. I didn't dig into the code to find out how you're setting this, but I've used{ 'prefers-color-scheme': 'dark' }
on CDP (with EmulationMedia) to get that to render properly.The text was updated successfully, but these errors were encountered: