Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Bug: Actors is called before eventless actions if invoking an actor after eventless (always) transitions #5219

Open
Labels
@doonazif

Description

@doonazif

XState version

XState version 5

Description

Let say i have a machine like this:

asyncfunctioninvokeMe(){console.log("'next' state: should be second");}constmyMachine=setup({actions:{starting:()=>{console.log("'start' state: should be first");},},actors:{invoker:fromPromise(()=>invokeMe()),},}).createMachine({id:"myMachine",initial:"start",states:{start:{entry:"starting",always:"next",},next:{invoke:{id:"next",src:"invoker",onDone:"complete",},},complete:{type:"final",},},});

Eventhough thestart state is before thenext state, when we run the machine, the order of the console log output was:

  1. 'next' state: should be second
  2. 'start' state: should be first

Expected result

Whatever in thenext state would be executed after thestart state finished with its actions. So the output should be:

  1. 'start' state: should be first
  2. 'next' state: should be second

Actual result

The invoked actor in thenext state was executed before thestart state actions finished.

Reproduction

https://stackblitz.com/edit/github-pusrgdcr

Additional context

In the codesandbox reproduction, the problem doesn't happen if the machine is waiting for the event (i.e: it waits for the user to click the button).

But if theinitial prop of the machine is changed tostart (i.e: it will be transitioned without waiting for any event), then the problem would occur.

p/s: I also created the reproduction in a codesandbox:https://codesandbox.io/p/sandbox/invoke-after-entry-lwqlw6

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp