Skip to content

Bug:  #247

Description

@anselanza

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions