Cursor Plugin Convex Rule Async Handling

Always await promises in Convex functions to prevent unexpected behavior

KunanonJ Updated

File contents

Async Handling in Convex

Always await all promises in Convex functions. Not awaiting promises (e.g., await ctx.scheduler.runAfter, await ctx.db.patch, await ctx.db.insert) may cause unexpected behavior.

Examples

Bad:

export const updateUser = mutation({
  handler: async (ctx, args) => {
    ctx.db.patch(args.userId, { name: args.name }); // Missing await
  }
});

Good:

export const updateUser = mutation({
  handler: async (ctx, args) => {
    await ctx.db.patch(args.userId, { name: args.name });
  }
});

Enable the no-floating-promises ESLint rule to catch these errors.

KunanonJ/ai-skills-hub/tree/main/skills/cursor-plugin-convex-rule-async-handling commit 76a9ca696a

Frequently asked questions

npx skillmds@latest add kunanonj/cursor-plugin-convex-rule-async-handling