Problem with internalAction
I'm calling this like this:
const updatedRows: string[][] = await ctx.scheduler.runAfter(
0,
internal.files.handleBatchEnhance,
{
batch,
resourceColumnIndex: args.resourceColumnIndex,
actionType: args.actionType,
userId: args.userId,
profileSummarizationHeaderIndex:
args.profileSummarizationHeaderIndex,
companyInfoHeaderIndex: args.companyInfoHeaderIndex,
offering: args.offering,
resultColumnIndex: args.resultColumnIndex,
}
);
And it returns: kc2bcfhssjzpryzj28casn202572k8qa
But when i change this from internalAction to normal function it returns an array of rows as it should with the exact same code inside. When i run the handleBatchEnhance action in convex dashboard it also works so i guess I'm doing something wrong when calling this internal action.
3 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
Running a function via the scheduler using
ctx.scheduler.runAfter
(or .runAt
) queues up the function to run as a side process, and as such any return from the function is lost. What you're getting back is the ID of the scheduled function in case you want to cancel it before it runs.
If you need the result, then you need to call it using one of the non-scheduling-related functions like runQuery
, runMutation
or runAction
For example if handleBatchEnhance
is an action, it might look like this:
thank you very much, somehow i haven't come across this runAction method before