T
TanStack3y ago
rival-black

Mutations started in offline mode are executed 1-by-1 after going online

- I enter "simulate offline mode" using the react-query dev tools. - I click a button 5 times, which causes 5 mutations (POST to /todo/create) - useIsMutating() correctly returns '5' since these mutations are paused or waiting for online - I 'go online' using the react-query dev tools. expected behavior: The 5 mutations are fired off in parallel actual behavior: The 5 mutations are fired synchronously, waiting 1-by-1 for the previous one to success Is there a way to make them fire off all together? Use case: An app in an area with poor internet connection. User executes tasks. When he received internet (wifi) connection I want to send his tasks to the server ASAP before he loses connection again. Repo: https://github.com/ThomasStock/offlineapp2 "npm install" in root folder, ./app and ./server "npm run dev" in root folder open in browser: http://localhost:5173/ in the react-query dev tools go in 'offline mode' by clicking wifi icon click "create task" 5 times go in online mode See in network traffic that mutations are executed 1-by-1
GitHub
GitHub - ThomasStock/offlineapp2
Contribute to ThomasStock/offlineapp2 development by creating an account on GitHub.
4 Replies
like-gold
like-gold3y ago
This is per design
rival-black
rival-blackOP3y ago
I figured something like that but what is the reasoning and can I bypass this? or is that a terrible idea
like-gold
like-gold3y ago
We can't know the impact of mutations. E.g. update an entry, then delete it. We can't run those in parallel. Running them one after the other is the safe thing
mere-teal
mere-teal2y ago
is there a way to setup config in such a way, that on reconnect to internet, first all the mutations resumes and then only queries starts invalidating ?

Did you find this page helpful?