Repository navigation
Fix #1484 mutation not calling onSettled if onError throws - #4939
arthurgeron wants to merge 5 commits into
Conversation
causes the state to not be cleaned up before the next error flow starts
the bug caused the mutation to freeze and always report a loading state
|
The latest updates on your projects. Learn more about Vercel for Git 鈫楋笌 1 Ignored Deployment
|
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 125fc29:
|
|
Not sure about your bug reproduction, can't get it to work (
we're winding up correctly in an error state due to the existing |
|
I've tested the link here in incognito and it reproduced the bug correctly, the mutation fails but gets stuck in a loading state, you can see it in this video:
Yes getting to an error state is what should happen, in reality it winds up in a loading state which does not change unless another mutation is triggered |
|
can you please try to make it fail in my reduced example please |
I've reproduced it in your example but quite inconsistently, we could be dealing with two different bugs here: 1- The one I reported which might only exist in React Query and not TanStack. I strongly believe that might be the case because it's easily reproduced as you can see in the codesandbox I've forked from the gallery and modified, no timeouts needed. Still it might be important to fix it for users that haven't migrated; 2 - The one I reproduced in the first sandbox and again here but with no throws in onError, |
yeah I see it now - the promise never gets rejected because accessing if you'd use an async function instead and added some I'm gonna close this PR because I don't think there is an issue in the current version of Tanstack query. |
When onError throws it aborts the current scope and dispatches another "error" state without finishing (e.g. calling onSetlled), it'd also never report the exception by calling onError with it or log it to console, which causes the mutation to freeze and always report a loading state as reported here
Bug can be reproduced here