-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure spawned actors are present in state.children. Fixes #795 #1553
Conversation
🦋 Changeset detectedLatest commit: c0309a1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@@ -844,17 +849,14 @@ export class Interpreter< | |||
: serviceCreator; | |||
|
|||
if (isPromiseLike(source)) { | |||
this.state.children[id] = this.spawnPromise( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
q: so those were setting the child on the not-yet-updated this.state
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember the specifics, but these did appear on the updated this.state
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, so I've jumped into the code to understand this a little bit better and this is what I've learns - spawn
is not handled by this part of the code at all, this is processing of start
actions (so basically for starting invokes / activities) and that's why this has not been working. This is IMHO a very strong candidate for the refactor in v5 because invoke/spawn should IMHO behave in the very same way. The only difference should be that invokes are static and bound to state whereas spawned actors are dynamic.
However, right now they differ because invokes are more lazy and spawns are eager. For example if an invoke gets "immediately" cancelled within a single macrotask then it is not even started (according to the SCXML spec statesToInvoke
are only processed after the internalQueue
gets empty), but spawn
does not behave in this way as it's eager (handled right away, rather than deferred to the end of the current macrotask).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but
spawn
does not behave in this way as it's eager (handled right away, rather than deferred to the end of the current macrotask).
This behavior is fixed in the next
branch already. Spawned actors will behave exactly the same way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's great to hear 🚀
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
This PR ensures that all actors (spawned/invoked) are represented in
state.children
.