fix(statechart, overmind): await async exit actions, fix devtools actions, fix throttle stale value#655
Merged
ericsorenson merged 1 commit intonextfrom Apr 4, 2026
Merged
Conversation
…ions, fix throttle stale value
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
henri-hulski
approved these changes
Mar 28, 2026
Member
henri-hulski
left a comment
There was a problem hiding this comment.
Great work! Good you take a look at statecharts, another package which didn't get much care.
BTW if you fix different task in a PR you can use several commits. One commit is one entry in the release notes (which replaces the changelog). So for every entry in the release notes you need to create a separate commit.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
onInitializeOvermindas a transition action after state changesBug Fixes
1. Statechart: async exit actions not awaited before transitions
When a statechart exit action was async (plain
async functionor operator-based viapipe), the returnedPromise was discarded. The main action, state transition, and entry actions executed immediately without
waiting for exit to complete.
The
runActionwrapper now collects exit action return values, detects Promises viaisPromise, andPromise.all()s them before proceeding. After async exits complete, it re-validates the transition isstill valid since another action may have changed state during the async gap. The synchronous code path
is unchanged.
2. Statechart: wrong actions object passed to devtools
After a state transition, the devtools update used
config.actions(which includesonInitializeOvermind)instead of
copiedActions(which has it removed). The other two call sites already usedcopiedActionscorrectly.
3. Throttle operator passes stale value
The throttle operator's
setTimeoutclosure capturedvaluefrom the first invocation. Subsequent callsupdated
currentNextbut not the value inside the already-scheduled timeout. Added acurrentValuevariable updated on every invocation so the timeout fires with the most recent value.
Other Changes
isPromisefrom overmind's public API soovermind-statechartcan import it instead ofduplicating the implementation