Skip to main content

Duplicate-proof workflow starts

With workflow 5.4, start() can claim a hook token as it starts a run, so a retried webhook or a double click never starts the same run twice.

Author
Sean WhitemanFounder, Easel.sh
Published
Product
Functions

Easel Workflows supports workflow 5.4’s start hooks. Pass a token you already have, such as an order ID, and start() starts the run and claims the token in one step:

import { start } from "workflow/api";
import { fulfillOrder } from "@/workflows/fulfill-order";

await start(fulfillOrder, [order], {
  experimental_hook: { token: `order:${order.id}` },
});

A second start() with the same token throws HookConflictError naming the run that owns it, and never starts a second run. That makes a webhook handler safe to retry: the provider can deliver the same event twice and your workflow runs once.

See Workflows.

All updates

Start deploying

Free to start. Import a repository and get a production URL in a few minutes.