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

Ensure actions are executed from a restored initial state. #1183

Merged
merged 3 commits into from
May 10, 2020

Conversation

davidkpiano
Copy link
Member

The issue was that when restoring from an initial state, state.actions weren't being resolved against the specified machine.options.actions action mapping, so actions weren't being executed.

Fixes #1174

@changeset-bot
Copy link

changeset-bot bot commented May 10, 2020

🦋 Changeset is good to go

Latest commit: 5b0c2f4

We got this.

This PR includes changesets to release 7 packages
Name Type
xstate Minor
@xstate/analytics Major
@xstate/graph Major
@xstate/immer Major
@xstate/react Major
@xstate/test Major
@xstate/vue Major

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

@davidkpiano davidkpiano requested a review from Andarist May 10, 2020 18:27
@codesandbox-ci
Copy link

codesandbox-ci bot commented May 10, 2020

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 5b0c2f4:

Sandbox Source
infallible-mcnulty-88pz5 Configuration
flamboyant-pond-jor2k Configuration

.changeset/wet-swans-deny.md Show resolved Hide resolved
packages/core/test/interpreter.test.ts Outdated Show resolved Hide resolved
@davidkpiano davidkpiano merged commit b967db6 into master May 10, 2020
@davidkpiano davidkpiano deleted the davidkpiano/1174 branch May 10, 2020 21:39
@github-actions github-actions bot mentioned this pull request May 10, 2020
@Andarist
Copy link
Member

I'm having second thoughts - actions are being considered fire and forget, so this is very likely that actions for a particular state has already been executed and only after that the state has been persisted and rehydrated later. In such a case action would be fired twice - which is not necessarily always a good thing. It should be up to a developer to decide about this because we don't know what's their strategy for persistence & rehydration.

@davidkpiano
Copy link
Member Author

Regardless, this PR is still correct, because there is a bug where actions aren't being resolved correctly, even though they should. The fix is general.

The behavior of whether or not those resolved actions should be executed is a separate issue, but I agree, it should be addressed.

@Andarist
Copy link
Member

👌

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.

Warning "No implementation found for action type" shown when starting machine from persisted state
2 participants