Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/retain-interrupted-start.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"effect-machine": patch
---

Keep an interrupted first `actor.start` until the actor is stopped. A later `start` again returns the first start's interruption and does not run recovery or the startup again. `Effect.cached` drops an interrupted run since effect 4.0.1, so the actor now keeps the first start's exit itself.
14 changes: 7 additions & 7 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"gate": "bun run typecheck && bun run test"
},
"dependencies": {
"effect": "4.0.0"
"effect": "4.1.7"
},
"devDependencies": {
"@types/bun": "1.4.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
},
"dependencies": {
"@effect-machine/examples-shared": "file:../shared",
"@effect/atom-react": "4.0.0",
"effect": "4.0.0",
"@effect/atom-react": "4.1.7",
"effect": "4.1.7",
"motion": "13.1.1",
"react": "19.2.8",
"react-dom": "19.2.8"
Expand Down
2 changes: 1 addition & 1 deletion examples/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"gate": "bun run typecheck"
},
"dependencies": {
"effect": "4.0.0"
"effect": "4.1.7"
},
"devDependencies": {
"typescript": "7.0.2"
Expand Down
4 changes: 2 additions & 2 deletions examples/solid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
},
"dependencies": {
"@effect-machine/examples-shared": "file:../shared",
"@effect/atom-solid": "4.0.0",
"effect": "4.0.0",
"@effect/atom-solid": "4.1.7",
"effect": "4.1.7",
"solid-js": "1.9.15",
"solid-transition-group": "0.3.0"
},
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
"@changesets/changelog-github": "1.0.1",
"@changesets/cli": "3.0.2",
"@effect-machine/examples-shared": "file:./examples/shared",
"@effect/atom-react": "4.0.0",
"@effect/atom-solid": "4.0.0",
"@effect/atom-react": "4.1.7",
"@effect/atom-solid": "4.1.7",
"@effect/tsgo": "0.47.2",
"@solidjs/testing-library": "0.8.10",
"@testing-library/react": "16.3.3",
Expand All @@ -65,7 +65,7 @@
"@types/react-dom": "19.2.7",
"@vitejs/plugin-react": "6.1.1",
"concurrently": "10.0.5",
"effect": "4.0.0",
"effect": "4.1.7",
"effect-bun-test": "0.3.0",
"jsdom": "30.0.1",
"lefthook": "2.1.12",
Expand Down
16 changes: 11 additions & 5 deletions src/actor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1364,9 +1364,14 @@ export const createActor = Effect.fn("effect-machine.actor.spawn")(function* <
}
}
});
// oxlint-disable-next-line effect/noPerCallCacheConstruction -- Actor allocation owns one startup result for this actor.
const start = yield* Effect.cached(
startupLock
// The first start's exit, interruption included, answers every later start. Effect.cached
// drops an interrupted run since effect 4.0.1, so the actor holds the exit itself.
const startExit = Deferred.makeUnsafe<void>();
let startRequested = false;
const start = Effect.suspend(() => {
if (startRequested) return Deferred.await(startExit);
startRequested = true;
return startupLock
.withPermit(
Effect.gen(function* () {
if (stopRequested) return undefined;
Expand All @@ -1380,8 +1385,9 @@ export const createActor = Effect.fn("effect-machine.actor.spawn")(function* <
return Fiber.join(starting);
}),
Effect.provide(serviceContext),
),
);
Effect.onExit((exit) => Deferred.done(startExit, exit)),
);
});

return buildActorRefCore(cell, stop, start, serviceContext);
});
Expand Down
Loading