Changelog

Singleton Functions: Cancel Mode

June 23, 2025

Singleton Functions now supports a new cancel mode in addition to the existing skip mode.

When using mode: "cancel", new function runs will cancel any existing run with the same key and start fresh, ensuring only the most recent execution proceeds. This is particularly useful for scenarios where you want to process the latest data and can safely discard in-progress work.

const latestDataSync = inngest.createFunction({
  id: "latest-data-sync",
  singleton: {
    key: "event.data.user_id",
    mode: "cancel",
  }  
},
{ event: "data-sync.start" },
async ({ event }) => {
  // Any existing run for this user will be cancelled
  const payload = await fetchLatestUserData(event.data.user_id);
  await applyRealTimeUpdates(payload);
});