Skip to content

Commit

Permalink
Fixed a runtime error when sending an empty array of events (#3520)
Browse files Browse the repository at this point in the history
* Fixed a runtime error when sending an empty array of events

* Don't create a fake `nextState` when receiving an empty batch

Co-authored-by: David Khourshid <davidkpiano@gmail.com>

Co-authored-by: David Khourshid <davidkpiano@gmail.com>
  • Loading branch information
Andarist and davidkpiano committed Sep 1, 2022
1 parent ddbc9bc commit 95a6a06
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/strange-bottles-punch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'xstate': patch
---

Fixed a runtime crash when sending multiple events as an array to a service. It is not recommended to use this feature though as it will be removed in the next major version.
4 changes: 4 additions & 0 deletions packages/core/src/interpreter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,10 @@ export class Interpreter<
);
}

if (!events.length) {
return;
}

this.scheduler.schedule(() => {
let nextState = this.state;
let batchChanged = false;
Expand Down

0 comments on commit 95a6a06

Please sign in to comment.