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
Actions cannot be inside mutations, since actions can be nondeterministic and have side effects. Can you share more details about your code?
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 withtaskId
andtext
, like call an API // then run another mutation to store the result }, });
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.