-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Description
Describe the bug
Exceptions thrown during the query refetch don't appear to be being caught.
Even in production, the console log is filled with
Uncaught (in promise) Error: fake error: 2
at index.js:52
at c (runtime.js:45)
at Generator._invoke (runtime.js:264)
at Generator.e.<computed> [as next] (runtime.js:98)
at r (asyncToGenerator.js:3)
at a (asyncToGenerator.js:25)
at asyncToGenerator.js:32
at new Promise (<anonymous>)
at asyncToGenerator.js:21
at react-query.mjs:812
before it crashes.
See https://codesandbox.io/s/charming-elgamal-286p8?file=/src/index.js for an example.
The hook sets the status to error based on the initial state, but it's hard to tell if it's does anything with the subsequent errors due to the other problems caused by them not being caught.
To Reproduce
Steps to reproduce the behavior:
- Go to https://codesandbox.io/s/charming-elgamal-286p8?file=/src/index.js
- wait 10s.
- See error
Note that in this example, Fake error 1 comes from the initial query, retry is disabled, and Fake Error 2 comes from the first refresh.
Expected behavior
Since the useQuery hook is returning the error status as well as the error object, I expect that that is the all that's required to handle the error.