Handling poor / no internet connection #2764
Replies: 3 comments
-
Thanks for the report Murray! If you want your app to presume it updated even when the network is down, you can achieve this using optimistic updates, combined with a fetch that waits til network connection is restored. An example of online/offline detection can be found here: /packages/core/src/manager/PollingSubscription.ts#L138 For reference, NetworkErrorBoundary catches any error that has a 'status' member. You can use a general error boundary component to catch other such errors. In the built in fetch (non-custom) there is a mechanism to add the status member for cases like CORS or network failures that would not normally result in a status member. |
Beta Was this translation helpful? Give feedback.
-
@ntucker great, thanks for the quick reply! I'll have a look at those and see what I can get working |
Beta Was this translation helpful? Give feedback.
-
The idea here is to provide a configuration where going offline doesn't result in errors but some downgraded experience is still available. However, to understand what sane defaults should be for this experience I would love some input from people building apps that need this capability. Let's start by defining the best behaviors first and possible configuration points. Once that is established we can work on shipping a universal solution. For those looking for solutions now, likely overriding NetworkManager will be sufficient. |
Beta Was this translation helpful? Give feedback.
-
Hi all,
Not marking this as a bug as potentially just my own misunderstanding of the docs. In brief, I’m struggling gracefully failing if internet connection drops out and an update is triggered.
I have a resource as such:
And I’m wrapping the various components in suspense and NetworkErrorBoundarys.
The resource works fine until there is an internet connection dropout. At this point the NetwrokErrorBoundary seems to be missed, leading to displaying the suspense’s loading spinner infinitely.
The behaviour I’d preferably like would be to cache the update data and try to send it again when there is an internet connection. Failing that, I’d like to stop attempting the update/PUT and display a no internet connection popup, keeping displaying the data before the update call. I’ve had no joy catching the error in the fetch and returning something to trigger an error as this breaks the expected data shape. Overall, I’m unsure if this behaviour (specifically missing the NetworkErrorBoundary) is expected and therefore is or isn’t a bug. Can anyone please advise on this or on my wider aims of handling this specific error?
Beta Was this translation helpful? Give feedback.
All reactions