Throwing Error in queryFn returns uncaught and unmounts entire app #5337
Replies: 4 comments 3 replies
-
further, what is |
Beta Was this translation helpful? Give feedback.
-
removed the side-effects from retry, nothing changed.
A function from the react-error-boundary hook : https://github.com/bvaughn/react-error-boundary#useerrorboundary-hook const { showBoundary } = useErrorBoundary();
True, but it would also take me 2 working days to get a complex example like this up and running. Just for you to see the exact same output mentioned above. |
Beta Was this translation helpful? Give feedback.
-
I've given up on making suspense and error boundary together work, set |
Beta Was this translation helpful? Give feedback.
-
Ok next question: why can't I call setState within onError? |
Beta Was this translation helpful? Give feedback.
-
Sorry in advance for not being able to share screenshots, I have to access the internet from work inside the slowest VM you've ever seen and I can't share any image etc. between this and VSC.
I'm trying to use TSQ in this case to poll an API that returns a "custom" status code contained in the response body. Status is either "In Progress", "Completed" or "Failed". Polling and the sucess-state work fine so far (using retry and a bit of wrangling), but I'm having issues dealing with the "Failed" state.
Whenever the simulation fails, the queryFn naturally throws an Error (as per the docs), but this error ends up not being caught and unmounts the entire React app, causing it to crash (see: https://legacy.reactjs.org/docs/error-boundaries.html - under "New Behavior for Uncaught Errors")
my console output looks like this:
query:
queryFn:
using TSQ version: "react-query": "^3.38.1",
and the react-error-boundary npm package ("react-error-boundary": "^4.0.2",)
weirdly, throwing a "simulation still in progress" error doesn't trigger anything, and the function keeps retrying...
I've also tried not using an errorBoundary but the behavior doesnt change,.
is there anyway to explicitly "catch" the error within the useQuery hook?
Beta Was this translation helpful? Give feedback.
All reactions