File tree Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Original file line number Diff line number Diff 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 (
You can’t perform that action at this time.
0 commit comments