From 951598b7d01952c0b5bb5a4c1c78faf33516dc94 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Sun, 12 Dec 2021 23:02:25 +0100 Subject: [PATCH] Commit to having onStop shutdownActions run in parent facet context --- packages/core/src/runtime/actor.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/core/src/runtime/actor.ts b/packages/core/src/runtime/actor.ts index f459c16..7ca9092 100644 --- a/packages/core/src/runtime/actor.ts +++ b/packages/core/src/runtime/actor.ts @@ -199,7 +199,11 @@ export class Facet { Turn.active._inFacet(this, () => { this.children.forEach(child => child._terminate(orderly)); - if (orderly) this.shutdownActions.forEach(a => a()); + if (orderly) { + Turn.active._inFacet(parent ?? this, () => { + this.shutdownActions.forEach(a => a()); + }); + } this.outbound.forEach(e => Turn.active._retract(e)); if (orderly) { @@ -315,9 +319,7 @@ export class Turn { this.stopActor(); } else { this.enqueue(facet, () => { - if (continuation) { - facet.onStop(() => Turn.active._inFacet(facetParent, continuation)); - } + if (continuation) facet.onStop(continuation); facet._terminate(true); }); }