Skip to content

Commit

Permalink
Fixed an issue with not clearing registered interpreters when their m…
Browse files Browse the repository at this point in the history
…achines reached final states (#3801)
  • Loading branch information
Andarist authored Jan 30, 2023
1 parent 51d2546 commit 10d0ba7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/silent-tips-occur.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'xstate': patch
---

Fixed an issue with not clearing registered interpreters when their machines reached final states.
11 changes: 6 additions & 5 deletions packages/core/src/interpreter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ export class Interpreter<
ActorRef<
TEvent,
State<TContext, TEvent, TStateSchema, TTypestate, TResolvedTypesMeta>
> {
>
{
/**
* The default interpreter options:
*
Expand Down Expand Up @@ -208,9 +209,8 @@ export class Interpreter<
public children: Map<string | number, ActorRef<any>> = new Map();
private forwardTo: Set<string> = new Set();

private _outgoingQueue: Array<
[{ send: (ev: unknown) => void }, unknown]
> = [];
private _outgoingQueue: Array<[{ send: (ev: unknown) => void }, unknown]> =
[];

// Dev Tools
private devTools?: any;
Expand Down Expand Up @@ -332,7 +332,7 @@ export class Interpreter<
) {
this.execute(this.state);
} else {
let item: typeof this._outgoingQueue[number] | undefined;
let item: (typeof this._outgoingQueue)[number] | undefined;
while ((item = this._outgoingQueue.shift())) {
item[0].send(item[1]);
}
Expand Down Expand Up @@ -382,6 +382,7 @@ export class Interpreter<
}
this._stop();
this._stopChildren();
registry.free(this.sessionId);
}
}
/*
Expand Down

0 comments on commit 10d0ba7

Please sign in to comment.