djbalinD
Convex Community14mo ago
6 replies
djbalin

Returning scheduled function id

Am I trippin or losing my mind - is is not possible to schedule an action in a mutation and return the scheduled function id? As soon as I attempt to return scheduledId in the function below, both the function declaration deleteUser and the scheduledId variable incur the TS error implicitly has type because it does not have a type annotation and is referenced directly or indirectly in its own initializer.

export const deleteUser = authMutation({
  returns: v.id('_scheduled_functions'),
  handler: async (ctx) => {
    const scheduledId = await ctx.scheduler.runAfter(0, api.act.testAction)
    return scheduledId
  },
})

// act.ts
export const testAction = action({
  handler: async (ctx) => {
    console.log('hey')
  },
})
Was this page helpful?