openclaw/src/cron/service/locked.ts
Peter Steinberger c379191f80 chore: migrate to oxlint and oxfmt
Co-authored-by: Christoph Nakazawa <christoph.pojer@gmail.com>
2026-01-14 15:02:19 +00:00

12 lines
342 B
TypeScript

import type { CronServiceState } from "./state.js";
export async function locked<T>(state: CronServiceState, fn: () => Promise<T>): Promise<T> {
const next = state.op.then(fn, fn);
// Keep the chain alive even when the operation fails.
state.op = next.then(
() => undefined,
() => undefined,
);
return (await next) as T;
}