docs
docs copied to clipboard
Add retry logic to fetch
What kind of changes does this PR include?
- Something else!
Description
Adds retry logic to our githubGet helper to try and mitigate the regular CI failures we get for “Invalid response body” when generating integration pages. Here’s a recent example: https://github.com/withastro/docs/runs/7837529942?check_suite_focus=true#step:4:18
Deploy Preview for astro-docs-2 ready!
| Name | Link |
|---|---|
| Latest commit | 9de5c7f6beef5ec4793d39a1a9ef8a585cc6e9b0 |
| Latest deploy log | https://app.netlify.com/sites/astro-docs-2/deploys/62fb84faa715220008afc273 |
| Deploy Preview | https://deploy-preview-1303--astro-docs-2.netlify.app |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site settings.
Thanks @hippotastic — yeah, this was quick and dirty, sorry! I’ll take a look at that suggestion. I’m also wondering if there’s a nice way to generalise this. We sometimes use fetch directly, other times githubGet.
Thanks @hippotastic — yeah, this was quick and dirty, sorry! I’ll take a look at that suggestion. I’m also wondering if there’s a nice way to generalise this. We sometimes use
fetchdirectly, other timesgithubGet.
No worries at all! The nice thing about p-retry (and most other similar libraries) is that you can simply wrap any function in it and it will support automatic retrying. If you want to bail out (e.g. due to invalid credentials), you just throw new AbortError(...) and it will stop retrying and the error will bubble up.
Ha I retract my approval! @hippotastic's suggestion is much better!
I used p-retry now as discussed and tested it locally by simulating a connection error. It's retrying in exponentially increasing intervals for up to 5 times now. PTAL @delucis and @natemoo-re :)
(Please disregard my self-approval. I tried to declare my old review with requested changes as outdated and this was the result. 😆)