The cancelExecution function cancels a pending or running execution by its ID. By default, cancelExecution can only cancel pending executions and throws an error if the execution is already running. The force option allows for the cancellation of a running execution.

import { cancelExecution } from "@defer/client";
import { sayHello } from "./defer/sayHello";

const { id } = await sayHello("John Doe");
await cancelExecution(id);

Options

force
boolean

Force the cancellation even if the execution is in running state.