Clever TaglineC
Convex Community5mo ago
13 replies
Clever Tagline

Issue scheduling an internal action from a helper function

I'm using Convex version 1.26.1. In one file I have an internal action defined like this:

import { internalAction } from "../../_generated/server";
import { v } from "convex/values";

export const sendInternalEmail = internalAction({
  args: {
    emailTo: v.union(v.string(), v.array(v.string())),
    subject: v.string(),
    message: v.string(),
    cc: v.optional(v.union(v.string(), v.array(v.string())))
  },
  handler: async (_, args) => {
    // logic here
  }
})


In a different file, I have a helper function where I'm passing ctx (typed as GenericActionCtx<any>). In that function I'm trying to schedule the above action like this:

await ctx.scheduler.runAfter(0, internal.it.internalEmail.sendInternalEmail, {
  emailTo: "email@example.com",
  subject: "subject",
  message: "message"
})


The internal.it.internalEmail.sendInternalEmail function reference is underlined, and hovering displays this error:

Type '{ sendInternalEmail: FunctionReference<"action", "internal", { cc?: string | string[] | undefined; message: string; emailTo: string | string[]; subject: string; }, null, string | undefined>; }' is missing the following properties from type 'SchedulableFunctionReference': _type, _visibility, _args, _returnType, _componentPath


I can't see any error in this setup. Any idea why it's claiming that there's a type mismatch?

For reference, here's what the kapa.ai bot said about this. Aside from the things it mentioned that were clearly not issues (e.g. passing an object instead of a function reference), I did try using ActionCtx instead of GenericActionCtx<any>, but the error was the same.
Was this page helpful?