Idempotency inside tasks

When you trigger runs you can provide an idempotencyKey in the options: https://trigger.dev/docs/v3/idempotency

This allows you to have idempotency but it can be a bit clunky having to create lots of separate tasks in some situations.

We should add a simple idempotency function you can use inside of tasks:

const result = await idempotent("an-idempotency-key", () => {
  return doSomething();
});

If the task failed and was reattempted, it would only ever execute that idempotent function once. The second time it would immediately return the cached result for the key you pass in ("an-idempotency-key").

Upvoters
Status

Rejected

Board

πŸ’‘ Feature Request

Date

Over 1 year ago

Author

Linear

Subscribe to post

Get notified by email when there are changes.