Catch exit hook failures

This commit is contained in:
Tony Garnock-Jones 2024-06-07 09:56:22 +02:00
parent 078c34632b
commit f45ab47175
1 changed files with 7 additions and 1 deletions

View File

@ -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);
}