-
-
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
Fixed an issue with initial state of invoked machines being read without custom data #1285
Conversation
🦋 Changeset is good to goLatest commit: 27bfd3a We got this. 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 |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 27bfd3a:
|
@@ -629,4 +629,45 @@ describe('transient states (eventless transitions)', () => { | |||
|
|||
service.send('ADD'); | |||
}); | |||
|
|||
it("shouldn't crash when invoking a machine with initial transient transition depending on custom data", () => { |
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.
This is not the best test as @davidkpiano's proposed workaround here is valid (to some extent). One should not rely on undefined context
- if TContext
parameter is configured then .context
should satisfy that constraint at all times and thus expressions (like guards) should not fail due to some properties being missed.
However, I don't know what other observable behavior to test at XState layer. The other added test (@xstate/react
) is much better: https://github.com/davidkpiano/xstate/pull/1285/files#diff-326fee0dc0480200270263670a5d51bfR608
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.
@davidkpiano do you think this test here is worth keeping?
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 think so, yes.
fixes #1277
This has a caveat though - in a normal situation a service creator is called here:
https://github.com/davidkpiano/xstate/blob/8226700aab94031f66133c6518430786aab4780c/packages/core/src/interpreter.ts#L871-L877
and it is called with different values -
_event
(norcontext
) is not guaranteed to be the same between those 2 points in time. I don't feel this is fixable easily in v4 though.