Repository navigation
Tags
Tags
fix: clear the transition when the context is canceled transitionFunc returns early when ctx.Err() != nil, but does not clear f.transition on the way out — only the completed path below it does. Since f.transition was already published before the context was ever checked, the FSM is left in transition permanently: every later Event returns InTransitionError, Can() returns false, and Transition() cannot help either, because it re-runs this same closure and takes this same early return. Only constructing a new FSM recovers. A state whose leave callback cancels is spared, because leaveStateCallbacks returning CanceledError clears the flag. A state with no callbacks at all is not — so whether a canceled context bricks the FSM depends on whether the state you happen to be leaving has a callback registered. Clears it with the same lock the completed path takes, and leaves e.Err untouched, so Event still returns the context error to the caller as before. Fixes #115. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>