fix(background-agent): handle async shutdown in process-cleanup signal handlers
This commit is contained in:
@@ -19,7 +19,7 @@ function registerProcessSignal(
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface CleanupTarget {
|
interface CleanupTarget {
|
||||||
shutdown(): void
|
shutdown(): void | Promise<void>
|
||||||
}
|
}
|
||||||
|
|
||||||
const cleanupManagers = new Set<CleanupTarget>()
|
const cleanupManagers = new Set<CleanupTarget>()
|
||||||
@@ -35,7 +35,9 @@ export function registerManagerForCleanup(manager: CleanupTarget): void {
|
|||||||
const cleanupAll = () => {
|
const cleanupAll = () => {
|
||||||
for (const m of cleanupManagers) {
|
for (const m of cleanupManagers) {
|
||||||
try {
|
try {
|
||||||
m.shutdown()
|
void Promise.resolve(m.shutdown()).catch((error) => {
|
||||||
|
log("[background-agent] Error during async shutdown cleanup:", error)
|
||||||
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log("[background-agent] Error during shutdown cleanup:", error)
|
log("[background-agent] Error during shutdown cleanup:", error)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user