How to handle network error and re-fetch from remote uri
See original GitHub issueHi, I would like to know how to deal with network error when I am loading images from remote uri. In my case, I have an infinite list to show all images in a listview. Somehow there may be some network errors:
- timeout
- no network connection
- ssl failed
I know I need to handle them inside the onError()
callback, but I want to implement a retry function. Something like retry 10 times, if the failed image is loaded successfully, then stop retrying. However, what annoys me is that I am not sure how to refetch the image from remote uri. What I can think is to set the CachedImage
to be null
and remount it to make it re-render.
Do you have any clue to implement this or add a new feature for us to set props like: timeout, retryNums
?
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (1 by maintainers)
Top Results From Across the Web
Handling operation errors - Apollo GraphQL Docs
Executing GraphQL operations on a remote server can result in GraphQL errors or network errors. GraphQL errors. These are errors related to the...
Read more >Implement error handling when using the Fetch API - web.dev
This article demonstrates some error handling approaches when working with the Fetch API. The Fetch API lets you make a request to a...
Read more >TypeError: Network request failed when fetching a file:// uri ...
I'm getting a network error exception. TypeError: Network request failed. and if I'm running with remote JS debug mode I can see this...
Read more >React Native fetch() Network Request Failed - Stack Overflow
1) To find out the exact error in the logs, I first enabled 'Debug JS Remotely' using Cmd + M on the app...
Read more >Using Service Workers - Web APIs | MDN
The service worker is now ready to process events. ... with the resource whose URL matches that of the network request, in each...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi, dear author. Sorry for the late reply. I have tried it in the
onError()
callback, but nothing being caught. As I mentioned before, I would like to catch the timeout error. However, it seems like the react-native does not support that feature #7952. Could you add a timeout feature, like opening a publicprop
for us to set the timeout value?@gameboyVito @aminroosta we found out the issue, this is related to how RNFetchBlob does not respect the 401 status code https://github.com/wkh237/react-native-fetch-blob/issues/267 so i have to explicitly not link the cache, and remove unlink the RNFetchBlib .
The second problem is HOW do i tell the custom image component that this download cause error, so i want the onError to be populated. so at the upper level of this component i can handle the Auth issue