-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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(gatsby): add timeout so fetching API info doesn't fail on very slow connections #17735
Conversation
…s (e.g. airplanes)
M gatsby/packages/gatsby/src/bootstrap/load-plugins/validate.js Lines 35 to 41 in 194a97c
And only in case of error: gatsby/packages/gatsby/src/bootstrap/load-plugins/validate.js Lines 106 to 115 in 194a97c
Errors are not so much here. That's why I ask:
|
Good question. @DSchau didn't you add this originally? Thoughts? |
@KyleAMathews yep -> #16105 (comment) Wouldn't reasonably slow connections short-circuit here and surpass the 1s limit? Perhaps that's OK. (i.e. faster than airplane, slower than "good") @muescha I like your idea to only fetch these APIs on error. That's a nicer solution. @KyleAMathews I'll PR some tweaks and get this merged! |
@KyleAMathews I tried a new approach in 4f812d7. This will only make the API request when bad exports are detected, which seems like a better approach. I added a few tests, and validated locally. Seems fine and would solve the underlying issue you identified as the API request will no longer be made in bootstrap unless there are bad exports. |
in case of timeout:
|
Maybe add also some meta data to the
|
Looks great! Yeah maybe have a timeout of e.g. five seconds. You could still fetch the data on bootstrap but just don't make the call blocking. |
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.
Added a small comment about unused arg. This looks good, by default axios does not timeout so probably best to add a timeout option like @KyleAMathews mentioned.
Co-Authored-By: Ward Peeters <ward@coding-tech.com>
It falls through to the catch block with
This is what it does. If you're using an API in a later version of Gatsby (but with an older version) you'll get a prompt as to what version it was introduced in. I've added a timeout (5s seems fair), this should be good to go. |
Going to merge and publish -- thanks Kyle for tagging me in! |
Successfully published gatsby@2.15.20 |
…ow connections (gatsbyjs#17735) * Add timeout so fetching API info doesn't fail on very slow connections (e.g. airplanes) * fix(gatsby): only make a network request for latest APIs on error * Update packages/gatsby/src/bootstrap/load-plugins/index.js Co-Authored-By: Ward Peeters <ward@coding-tech.com> * chore: Add a timeout * chore: fix tests
I was on an airplane trying to run
gatsby develop
and bootstrap hung here. I dug around and found adding a timeout fixed it.