statelyai / xstate

Actor-based state management & orchestration for complex app logic.
https://stately.ai/docs
MIT License
26.98k stars 1.24k forks source link

Bug: Spawned child machines should inherit the parent's clock #4837

Closed xylophonehero closed 5 months ago

xylophonehero commented 5 months ago

XState version

XState version 5

Description

When spawning a child machine, if a customised clock has been passed to the createActor options, then the customised clock is not inherited by the child machine

This is super important for testing where I want to manually trigger machine timeouts from the tests

Expected result

The clock on the spawned child should be the customised clock

Actual result

The spawned child uses the default clock

Reproduction

https://codesandbox.io/p/devbox/nostalgic-ardinghelli-j299lq

Additional context

Looking at the resolveSpawn function, we have access to the parents clock via actorScope.self.clock so the clock can easily be passed here

davidkpiano commented 5 months ago

Fixed by #4822