How to cancel a mutation when network is down
Take the
convex-tutorial
(the chat app), run it, use your dev tools to make the app Offline, type a message in the app, and hit Enter.
Nothing will happen until the app comes back online. Would there be a way to cancel the mutation after 30 seconds, so we can display an error message to the user, instead of leaving them hanging for a indefinite time?
(Also, just letting you know: I notice a high CPU consumption during the whole time the app is offline.)3 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
you can avoid blocking the user with optimistic updates https://docs.convex.dev/client/react/optimistic-updates . but i agree canceling a mutation would be reasonable and i don't think there's a way to do it. Also the CPU is a good call out
Optimistic Updates | Convex Developer Hub
Even though Convex queries are completely reactive, sometimes you'll want to
Thank you for your reply. Fortunately it shouldn't be a problem for the project I'm working on now. However, it makes me think that I might not be able to use Convex for some other projects.
I've read in other threads that the Convex team might implement Offline-First in the future 😉 That would be amazing. It might be one of the last reasons people would choose Firestore instead of Convex.