You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
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.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
The text was updated successfully, but these errors were encountered: