From f45ab471751197743e2790e8e57458e7abcc8282 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Fri, 7 Jun 2024 09:56:22 +0200 Subject: [PATCH] Catch exit hook failures --- packages/core/src/runtime/actor.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/core/src/runtime/actor.ts b/packages/core/src/runtime/actor.ts index 0296fb0..0a617f2 100644 --- a/packages/core/src/runtime/actor.ts +++ b/packages/core/src/runtime/actor.ts @@ -158,7 +158,13 @@ export class Actor { if (!reason.ok) { console.error(`${this} crashed:`, reason.err); } - this.exitHooks.forEach(hook => hook()); + this.exitHooks.forEach(hook => { + try { + hook(); + } catch (e) { + console.error(`${this} exit hook ${hook} failed:`, e); + } + }); this.root._terminate(reason.ok); this.space.deregister(this); }