charlieC
Convex Community11mo ago
6 replies
charlie

Are immediately scheduled functions FIFO?

i.e. if I write
export const doLotsOfThings = internalMutation({
  args: {},
  handler: async (ctx) => {
    const items = await ctx.db.query('items').collect()

    for (const item of items) {
      await ctx.scheduler.runAfter(0, internal.items.doSomethingToItem, {
        itemId: item._id,
      })
    }

    await ctx.scheduler.runAfter(0, internal.somethingElse.doSomeGlobalThing)
  },
})


is it guaranteed that all doSomethingToItem will have resolved before doSomeGlobalThing is called?
Was this page helpful?