ChrisLi
ChrisLi4w ago

mutation retries

I have a action inside a mutation. As we known the mutations will retry themselves when failed, will the acitons inside also be retried?
4 Replies
lee
lee4w ago
Actions cannot be inside mutations, since actions can be nondeterministic and have side effects. Can you share more details about your code?
ChrisLi
ChrisLiOP4w ago
Hi @lee , I mean in a mutation, I scheduled an Action example from documentations:
import { v } from "convex/values"; import { internal } from "./_generated/api"; import { internalAction, mutation } from "./generated/server"; export const mutationThatSchedulesAction = mutation({ args: { text: v.string() }, handler: async (ctx, { text }) => { const taskId = await ctx.db.insert("tasks", { text }); await ctx.scheduler.runAfter(0, internal.myFunctions.actionThatCallsAPI, { taskId, text, }); }, }); export const actionThatCallsAPI = internalAction({ args: { taskId: v.id("tasks"), text: v.string() }, handler: (, args): void => { // do something with taskId and text, like call an API // then run another mutation to store the result }, });
lee
lee4w ago
Cool. Scheduled actions do not get retried. If you want an action to be retried, you can use this https://www.convex.dev/components/retrier
Action Retrier
Add reliability to an unreliable external service. Retry idempotent calls a set number of times.
ChrisLi
ChrisLiOP4w ago

Did you find this page helpful?