fix(research): preserve CLI recovery receipts after journal failure (RP15)
This commit is contained in:
parent
14b28a3428
commit
e3d6512b8f
3 changed files with 247 additions and 4 deletions
|
|
@ -207,7 +207,11 @@ export async function runResearchCycle(
|
|||
error: error instanceof Error ? error.message : String(error),
|
||||
uncertain: error instanceof ResearchRequestError ? error.uncertain : true,
|
||||
};
|
||||
await options.onEvent(stopped);
|
||||
try {
|
||||
await options.onEvent(stopped);
|
||||
} catch (journalError) {
|
||||
throw new ResearchCycleStopped(stopped, journalError);
|
||||
}
|
||||
throw new ResearchCycleStopped(stopped, error);
|
||||
}
|
||||
}
|
||||
|
|
@ -495,11 +499,20 @@ if (import.meta.main) {
|
|||
2
|
||||
)
|
||||
);
|
||||
} finally {
|
||||
await journal.close();
|
||||
} catch (error) {
|
||||
// An acknowledged resource can be recoverable only through the primary error.
|
||||
await journal.close().catch(() => undefined);
|
||||
throw error;
|
||||
}
|
||||
await journal.close();
|
||||
} catch (error) {
|
||||
console.error(error instanceof Error ? error.message : String(error));
|
||||
console.error(
|
||||
error instanceof ResearchCycleStopped
|
||||
? JSON.stringify({ error: error.message, event: error.event })
|
||||
: error instanceof Error
|
||||
? error.message
|
||||
: String(error)
|
||||
);
|
||||
process.exitCode = 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue