Skip to content

Version Packages - #93

Merged
cevr merged 1 commit into
mainfrom
changeset-release/main
Oct 19, 2026
Merged

cevr merged 1 commit into
mainfrom
changeset-release/main

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.

Releases

effect-machine@0.31.0

Minor Changes

  • 1e2966a Thanks @cevr! - actor.subscribe, actor.client.subscribe and self.client.subscribe listeners now get every state written after they subscribe, each once, in write order, like the waits. A listener reads the states from the state ref's own publication, and a notification only wakes it. Before this change a supervised restart could deliver its restart state after a newer state of the new generation, a send from a listener callback could deliver the newer state to later listeners before the older one and call a listener again inside its own callback, a state whose entry crashed before its notification was never delivered, and a stop of an actor could drop the last write. Behavior changes: a listener that subscribes between a write and its notification, or inside another listener's callback, no longer gets that state (it was current when it subscribed; read getSnapshot for it). This includes a listener that a .spawn handler subscribes: it no longer gets the state that the handler runs for (0.30.0 delivered it); read the handler's state or getSnapshot() for it; a listener is not called again while its own callback runs, and gets the states its callback caused after it returns; the listeners of an actor get a write that a stop overtook before awaitExit completes; each subscribe call is its own registration, so the same function subscribed twice gets each write twice (the listeners were a set of functions before, which called it once), and each unsubscribe ends one registration. The ordering and terminal guarantees cover local actor listeners. An entity's self.client listener can still miss a write that the entity's deactivation overtakes, as in 0.30.0: the entity runtime does not ring its listeners at teardown.

  • 1469452 Thanks @cevr! - actor.waitFor, actor.awaitFinal and actor.sendAndWait now end when the actor terminates. They fail with ActorStoppedError (the error awaitOutput already uses) when the actor stops, drains, defects, or reaches a final state, and no state from the start of the wait matched. Before this change a wait never resolved after the actor terminated without a match, so callers had to race it against awaitExit or a time limit. The waits now read the states from the state ref's own publication: the predicate sees the snapshot and then every later state write, each once, in write order and one call at a time, and the wait returns the first match. A brief state around the start of the wait is no longer lost, a state counts as reached once it is written (also when its entry crashes later, when a supervised restart follows, or when a stop comes before its notification), the predicate is not called again after it matches, and a predicate that sends an event cannot re-enter the wait. sendAndWait starts to observe before it sends, and does not send when the predicate throws on the snapshot. A predicate that throws on a later state now fails the wait with that defect instead of being ignored. A state restored by recovery now notifies subscribe listeners and waiters. A wait releases its listener and its subscription when it ends, also when it is interrupted at any point. The error channel of all three widens from never to ActorStoppedError: code that annotates them as Effect<State> must handle or declare the new error.

@cevr
cevr merged commit 3e3c7b1 into main Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant