Skip to content
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 a regression that has caused machine.getInitialState(value) to not follow always transitions correctly #3599

Merged
merged 2 commits into from
Sep 13, 2022

Conversation

Andarist
Copy link
Member

fixes #3544

@changeset-bot
Copy link

changeset-bot bot commented Sep 13, 2022

🦋 Changeset detected

Latest commit: 64c721a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
xstate Patch

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

@ghost
Copy link

ghost commented Sep 13, 2022

👇 Click on the image for a new way to code review
  • Make big changes easier — review code in small groups of related files

  • Know where to start — see the whole change at a glance

  • Take a code tour — explore the change with an interactive tour

  • Make comments and review — all fully sync’ed with github

    Try it now!

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map Legend

@codesandbox-ci
Copy link

codesandbox-ci bot commented Sep 13, 2022

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 64c721a:

Sandbox Source
XState Example Template Configuration
XState React Template Configuration
solitary-smoke-qqyk4h Issue #3544

@@ -1661,7 +1664,7 @@ class StateNode<
return this.resolveTransition(
{
configuration,
entrySet: [...configuration],
entrySet: configuration,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It brings back a shared reference being used for both entrySet and for configuration. This is somewhat dangerous but I just hope that v5 algorithm works better in this regard.

It has been like that for a long time, I've "fixed" this problem here but that accidentally caused the mentioned regression. So now instead of copying the reference, I make sure that we don't push items to the entrySet that are already there:
https://github.com/statelyai/xstate/pull/3599/files#diff-7f553f4d4c285f1c05cced2e979c5b957d8884e39e74cc6797b32c63a0be7e7aR1015

}
});

const service = interpret(machine).start(machine.getInitialState('a'));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly, this doesn't follow always transitions:

-      const service = interpret(machine).start(machine.getInitialState('a'));
+      const service = interpret(machine).start('a');

I would consider this to be a bug too but it just never worked correctly and I don't think it's necessary to fix this in v4.

@Andarist Andarist merged commit 333f803 into main Sep 13, 2022
@Andarist Andarist deleted the fix/3544 branch September 13, 2022 12:40
@github-actions github-actions bot mentioned this pull request Sep 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: eventless transitions in parallel states not taken anymore when starting interpreter from given state
2 participants