From 20b83aa5a5014b55ff137e429ec11f7aa09b807c Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Thu, 9 Dec 2021 18:52:22 +0100 Subject: [PATCH] Support stopping a root facet, such as happens when a link between actors is broken --- packages/core/src/runtime/actor.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/core/src/runtime/actor.ts b/packages/core/src/runtime/actor.ts index 354c256..930a558 100644 --- a/packages/core/src/runtime/actor.ts +++ b/packages/core/src/runtime/actor.ts @@ -302,10 +302,14 @@ export class Turn { } stop(facet: Facet = this.activeFacet, continuation?: LocalAction) { - this.enqueue(facet.parent!, () => { - facet._terminate(true); - if (continuation) continuation(); - }); + if (facet.parent === null) { + this.stopActor(); + } else { + this.enqueue(facet.parent, () => { + facet._terminate(true); + if (continuation) continuation(); + }); + } } // Alias for syndicatec code generator to use