#mutation retries

1 messages · Page 1 of 1 (latest)

fallow plover
#

I have a action inside a mutation. As we known the mutations will retry themselves when failed, will the acitons inside also be retried?

steep kestrel
#

Actions cannot be inside mutations, since actions can be nondeterministic and have side effects. Can you share more details about your code?

fallow plover
#

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 with taskId and text, like call an API
// then run another mutation to store the result
},
});

steep kestrel