Check for and prevent cross-actor facet termination

This commit is contained in:
Tony Garnock-Jones 2024-03-10 12:47:05 +01:00
parent ce598e6954
commit 888b3be291
1 changed files with 3 additions and 0 deletions

View File

@ -366,6 +366,9 @@ export class Turn {
} }
stop(facet: Facet, continuation?: LocalAction) { stop(facet: Facet, continuation?: LocalAction) {
if (facet.actor !== Turn.activeFacet.actor) {
throw new Error("Attempt to terminate a facet in a different actor");
}
if (continuation) facet.onStop(continuation); if (continuation) facet.onStop(continuation);
facet._terminate(true); facet._terminate(true);
} }