don't restart entities on shutdown (#624)

This commit is contained in:
Tim
2025-10-07 11:00:53 +13:00
committed by GitHub
parent 0efc80d6ea
commit eb47328ca8
2 changed files with 8 additions and 2 deletions
@@ -273,11 +273,14 @@ export const make = Effect.fnUntraced(function*<
)
function onDefect(cause: Cause.Cause<never>): Effect.Effect<void> {
if (!activeServers.has(address.entityId)) {
return endLatch.open
}
const effect = writeRef.rebuildUnsafe()
defectRequestIds = Array.from(activeRequests.keys())
return Effect.logError("Defect in entity, restarting", cause).pipe(
Effect.andThen(Effect.ignore(retryDriver(void 0))),
Effect.andThen(effect),
Effect.flatMap((_) => activeServers.has(address.entityId) ? effect : endLatch.open),
Effect.annotateLogs({
module: "EntityManager",
address,
@@ -68,7 +68,7 @@ export class ResourceRef<A, E = never> {
return Effect.interrupt
}
const prevScope = s.scope
const scope = Effect.runSync(Scope.make())
const scope = Scope.makeUnsafe()
this.latch.closeUnsafe()
MutableRef.set(this.state, { _tag: "Acquiring", scope })
return Effect.withFiber((fiber) => {
@@ -77,6 +77,9 @@ export class ResourceRef<A, E = never> {
}).pipe(
Effect.andThen(this.acquire(scope)),
Effect.flatMap((value) => {
if (this.state.current._tag === "Closed") {
return Effect.interrupt
}
MutableRef.set(this.state, { _tag: "Acquired", scope, value })
return this.latch.open
})