-
-
Notifications
You must be signed in to change notification settings - Fork 67
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
Does not support network failures from cross-fetch module #43
Comments
I've opened up a PR here in case this is acceptable to add #44 |
Can you open an issue on |
hey @sindresorhus, thanks for getting back to me! I agree with that idea in principle. However, I imagine it's going to be quite the ask to get a well established module to make a breaking change like this (lots of try/catch code out there looking for that exact text) simply to fit with this module. Thinking about the underlying issue a bit further, network error messages are really complicated because they are browser and even OS language dependent (checkout this comment from the sentry sdk where they're dealing with the same issue). We've seen this in practice where our sentry logs are filled with error requests in different languages that were not captured by I wonder if perhaps there's a better mechanism for detecting these errors rather than matching on message text? Anyways, at the very least, it might be a nice solution to simply allow for a function to be passed in that could take in the error and return a boolean as to whether or not the error should be retried by |
I second the notion of having a custom import pRetry, { defaultShouldBeRetried } from "p-retry";
// …
await pRetry(run, {
shouldBeRetried: (err) => {
if (!defaultShouldBeRetried(err)) {
// only check for cases where exportedShouldBeRetried is too restrictive
}
},
}); @sindresorhus happy to hear your opinion on this. I'd be glad to draft a PR in case you think it's worthwhile. |
Does the root of the issue really lie in
Thus, I'd say the issue lies in GitHub's polyfill and maybe
Wow, really? 😱 Although the spec is kind of a mess in this regard by throwing |
I agree it's not an easy ask, but I would argue it's always worth trying. I usually ask for this when people submit workaround as I would like to have at least have a small chance of being able to remove the workaround at some point in the future. And it's not like they have to do a breaking change right away. They can plan to include it for the next major release or something. I don't expect it to happen right away.
There unfortunately isn't. I really wish JS had stronger typing/conventions for errors in general. At least with Node.js, they're being pretty consistent with using the I would recommend participating in whatwg/fetch#526 |
I would prefer to keep the default behavior of retrying on network errors. But an option like what you proposed makes sense regardless. We could potentially add a |
I'm using cross-fetch in a number of projects since it allows polymorphic code across react-native, node and browser. The library has quite a bit of traction at this point (in use by 301K projects as of this writing according to github).
Currently this library doesn't support the network error text that is emitted by
cross-fetch
when a network error occurs. So it treats it as a general error and does not retry.https://github.com/lquixada/cross-fetch/blob/main/dist/browser-ponyfill.js#L480
Would be great if p-retry could include this error into the list of
networkErrorMsgs
The text was updated successfully, but these errors were encountered: