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

Bug: #247

Open
anselanza opened this issue Nov 5, 2024 · 0 comments
Open

Bug: #247

anselanza opened this issue Nov 5, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@anselanza
Copy link

Description

XState version

XState version 5

Description

I have reduced this to a very simple, reproducible example at https://stately.ai/registry/editor/9ef8a9f6-fcef-4bbc-8e29-0e5d80c0d523?machineId=b68ae09b-11e3-4675-9bda-97a7a7504db0&mode=Simulate

An "after" (delayed) transition works as expected when simulating. But only if there is no guard condition on the transition.

As soon as there is a guard condition, even if that guard is trivial (it always returns true), the timeout is reached but the transition never happens.

In the screenshot below, notice that the "after 1 sec" event gets logged, but no transition to the "Active" state happens. Unless, of course, you explicitly click on the button for xstate.after(1000)#(machine).waiting which sort of defeats the purpose of simulating a delayed transition, and in any case behaves differently to the case in which there is no guard.

Screenshot 2024-11-05 at 16 53 20

Expected result

I would expect that, when simulating, guards would be evaluated after the given delay and, if evaluated to true, the transition to the target state should occur.

Actual result

The simulation works as expected if the guard is removed (the machine transitions to the target state after the delay), but when a guard is present then the timeout is logged but no transition actually happens.

Reproduction

https://stately.ai/registry/editor/9ef8a9f6-fcef-4bbc-8e29-0e5d80c0d523?machineId=b68ae09b-11e3-4675-9bda-97a7a7504db0&mode=Simulate

Additional context

using Xstate v5

Expected result

Should transition automatically when simulated, provided the guard condition evaluates to true.

Actual result

Timeout is logged but the machine does not transition to the target state.

Which browsers are you seeing the problem on?

Chrome

Additional details

No response

@anselanza anselanza added the bug Something isn't working label Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant