Last active
February 20, 2020 20:30
-
-
Save keeth/d5d94dab40b4d697618c075e155197da to your computer and use it in GitHub Desktop.
Is it a fetch network error? (for the purpose of retrying on failure).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
https://twitter.com/xinganwang/status/1189266788237885443 | |
github/fetch: TypeError: Network request failed | |
Chrome: TypeError: Failed to fetch | |
Firefox: TypeError: NetworkError when attempting to fetch resource. | |
Safari: TypeError: The Internet connection appears to be offline. | |
*/ | |
const isNetworkError = e => | |
/The Internet connection appears to be offline|Failed to fetch|Network request failed|NetworkError when attempting to fetch resource|The network connection was lost/.test( | |
e.message | |
) || | |
e.statusCode === 502 || | |
e.statusCode === 504; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment