fix(core): make sendParent a no-op when actor has no parent - #5552
Open
JSap0914 wants to merge 1 commit into
Open
fix(core): make sendParent a no-op when actor has no parent#5552JSap0914 wants to merge 1 commit into
JSap0914 wants to merge 1 commit into
Conversation
Previously, calling sendParent() from a root (parentless) actor would cause the actor to enter an error state with the message: "Unable to send event to actor '#_parent' from machine '(machine)'." This contradicts the documented behaviour where sendParent sends an event to the parent "if it exists". The fix returns a no-op resolution from resolveSendTo when the target is SpecialTargets.Parent and no parent actor exists, and guards the matching execute/retryResolve helpers against undefined params. Fixes statelyai#5120
🦋 Changeset detectedLatest commit: 22c4e81 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #5120.
sendParent()is documented as sending an event to the parent actor "if it exists", but calling it from a root (parentless) actor previously caused the actor to enter an error state with:This fix makes
sendParentsilently skip when there is no parent, matching the documented semantics.Root cause
In
resolveSendTo(packages/core/src/actions/send.ts), when the resolved target isSpecialTargets.ParentandactorScope.self._parentisundefined, the existing guardif (!targetActorRef) { throw ... }did not distinguish the#_parentcase from genuinely missing named actors.Fix
[snapshot, undefined, undefined]resolution whenresolvedTarget === SpecialTargets.Parentand no parent exists.retryResolveSendToandexecuteSendToto early-return onundefinedparams (which only occurs via this path).'active'aftersendParentfires with no parent.