Is there a way to wait for what an internalAction returns?

I have a mutation that updates user data this mutation calls an internal action to update the user data in Clerk too. This action can fail sometimes, for example if an email doesnt meet all requirements. In this case we would need to catch the error in the action give it back to the mutation and then give it back to the client. How can I do that?
13 Replies
Convex Bot
Convex Bot•2mo ago
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!
jamwt
jamwt•2mo ago
the result of the mutation is probably commited ultimately by an action, if the action succeeds this result could just potentially be some kind of error state and it's still a mutation that uses convex's reactive queries to return the outcome of the background action
FleetAdmiralJakob 🗕 🗗 🗙
Wdym? The scheduler needs to call the action, right? So how will what happens in the action affect what happens in the mutation? Its gone and has nothing to do with the action anymore, right?
ampp
ampp•2mo ago
I have been all over on this one, we currently treat clerk as the source of truth so we don't push any updates right now. We just see if any of the data changes and make the clerk update like in the ents saas-starter. At first i could verify that a change was made via a webhook call. Our custom event system saves scheduled function Id's when you schedule them and updates the event, then you have that id to check if things. Then i made a ui button and function to manually retry it, which takes the scheduled function id and reuses the arguments. I was planning to use the action retrier component eventually for clerk
FleetAdmiralJakob 🗕 🗗 🗙
Yeah we are doing it the opposite way around with treating Convex as our source of truth and updating Clerk accordingly Should we switch? If not how can we solve the problem?
ampp
ampp•2mo ago
The easiest thing is to just toss the actionRetrier into the action. Then you know if something failed to run.
FleetAdmiralJakob 🗕 🗗 🗙
Ah interesting. Nice, I will try it out
FleetAdmiralJakob 🗕 🗗 🗙
Convex
Action Retrier
Add reliability to an unreliable external service. Retry idempotent calls a set number of times.
FleetAdmiralJakob 🗕 🗗 🗙
Btw. Why is this one not in the core convex library?
jamwt
jamwt•2mo ago
More and more features will show up in eg components. We’ll work on the discoverability via better docs soon!
FleetAdmiralJakob 🗕 🗗 🗙
Ok, interesting. But isnt this more boilerplate for cases like the action retrier? I mean it probably makes sense for bigger features but couldnt this thing be in the convex-helpers package too?
jamwt
jamwt•2mo ago
it's likely to be part of some sort of larger workflow vision

Did you find this page helpful?