fix: restore cron manual run type narrowing

This commit is contained in:
Peter Steinberger 2026-03-13 16:49:50 +00:00
parent acfb95e2c6
commit 49f3fbf726
1 changed files with 12 additions and 2 deletions

View File

@ -403,7 +403,10 @@ async function inspectManualRunDisposition(
mode?: "due" | "force", mode?: "due" | "force",
): Promise<ManualRunDisposition | { ok: false }> { ): Promise<ManualRunDisposition | { ok: false }> {
const result = await inspectManualRunPreflight(state, id, mode); const result = await inspectManualRunPreflight(state, id, mode);
if (!result.ok || !result.runnable) { if (!result.ok) {
return result;
}
if ("reason" in result) {
return result; return result;
} }
return { ok: true, runnable: true } as const; return { ok: true, runnable: true } as const;
@ -415,9 +418,16 @@ async function prepareManualRun(
mode?: "due" | "force", mode?: "due" | "force",
): Promise<PreparedManualRun> { ): Promise<PreparedManualRun> {
const preflight = await inspectManualRunPreflight(state, id, mode); const preflight = await inspectManualRunPreflight(state, id, mode);
if (!preflight.ok || !preflight.runnable) { if (!preflight.ok) {
return preflight; return preflight;
} }
if ("reason" in preflight) {
return {
ok: true,
ran: false,
reason: preflight.reason,
} as const;
}
return await locked(state, async () => { return await locked(state, async () => {
// Reserve this run under lock, then execute outside lock so read ops // Reserve this run under lock, then execute outside lock so read ops
// (`list`, `status`) stay responsive while the run is in progress. // (`list`, `status`) stay responsive while the run is in progress.