Skip to content

Commit 0455daa

Browse files
committed
wip
1 parent a163571 commit 0455daa

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

packages/cluster/src/Sharding.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,17 +1239,19 @@ const make = Effect.gen(function*() {
12391239
closed: false,
12401240
manager
12411241
}
1242-
entityManagers.set(entity.type, state)
1243-
if (entityManagerLatches.has(entity.type)) {
1244-
entityManagerLatches.get(entity.type)!.unsafeOpen()
1245-
entityManagerLatches.delete(entity.type)
1246-
}
1242+
1243+
// register entities while storage is idle
1244+
// this ensures message order is preserved
1245+
yield* withStorageReadLock(Effect.sync(() => {
1246+
entityManagers.set(entity.type, state)
1247+
if (entityManagerLatches.has(entity.type)) {
1248+
entityManagerLatches.get(entity.type)!.unsafeOpen()
1249+
entityManagerLatches.delete(entity.type)
1250+
}
1251+
}))
12471252

12481253
yield* PubSub.publish(events, EntityRegistered({ entity }))
1249-
},
1250-
// register entities while storage is idle
1251-
// this ensures message order is preserved
1252-
withStorageReadLock
1254+
}
12531255
)
12541256

12551257
yield* Scope.addFinalizerExit(

0 commit comments

Comments
 (0)