/** These bounds apply to lifecycle control work, never to healthy provider execution. */ export const EXECUTION_CONTROL_DEADLINE_MS = 60_000; export const EXECUTION_RECONCILIATION_INTERVAL_MS = 15_000; export async function boundedExecutionCleanup( operation: () => Promise, timeoutMs = EXECUTION_CONTROL_DEADLINE_MS, ): Promise { let timer: ReturnType | undefined; try { await Promise.race([ Promise.resolve() .then(operation) .catch(() => undefined), new Promise((resolve) => { timer = setTimeout(resolve, timeoutMs); timer.unref?.(); }), ]); } finally { if (timer) clearTimeout(timer); } }