#mutation retries
1 messages · Page 1 of 1 (latest)
Actions cannot be inside mutations, since actions can be nondeterministic and have side effects. Can you share more details about your code?
Hi @steep kestrel , 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 withtaskIdandtext, 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