refactor(core): decouple run settling from terminal status transition

Resolve #running before the terminal statuschange so the settle signal can
never be lost to re-entrant listeners. Hooks keep middleware semantics:
a throwing hook fails the run; integrations that don't want this should
suppress errors in their own hooks. Also make suppress() async-aware so
rejected promises (e.g. showMask) are actually caught.
This commit is contained in:
Simon
2026-06-11 17:21:11 +08:00
parent 8f9a637bdb
commit 4690aefec5
2 changed files with 9 additions and 14 deletions

View File

@@ -133,9 +133,9 @@ export function assert(condition: unknown, message?: string, silent?: boolean):
/**
* Suppress errors from a function.
*/
export function suppress<T>(fn: () => T): T | undefined {
export async function suppress<T>(fn: () => T | Promise<T>): Promise<Awaited<T> | undefined> {
try {
return fn()
return await fn()
} catch (error) {
console.error(error)
return undefined