@@ -917,6 +917,7 @@ export class ActorInstance<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
917917 state : CS ,
918918 driverId : ConnectionDriver ,
919919 driverState : unknown ,
920+ subscriptions : string [ ] ,
920921 authData : unknown ,
921922 ) : Promise < Conn < S , CP , CS , V , I , DB > > {
922923 this . #assertReady( ) ;
@@ -950,6 +951,11 @@ export class ActorInstance<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
950951 //
951952 // Do this immediately after adding connection & before any async logic in order to avoid race conditions with sleep timeouts
952953 this . #resetSleepTimer( ) ;
954+ if ( subscriptions ) {
955+ for ( const sub of subscriptions ) {
956+ this . #addSubscription( sub , conn , true ) ;
957+ }
958+ }
953959
954960 // Add to persistence & save immediately
955961 this . #persist. connections . push ( persist ) ;
@@ -1017,6 +1023,7 @@ export class ActorInstance<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
10171023 return await this . executeAction ( ctx , name , args ) ;
10181024 } ,
10191025 onSubscribe : async ( eventName , conn ) => {
1026+ console . log ( "subscribing to event" , { eventName, connId : conn . id } ) ;
10201027 this . inspector . emitter . emit ( "eventFired" , {
10211028 type : "subscribe" ,
10221029 eventName,
@@ -1489,6 +1496,13 @@ export class ActorInstance<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
14891496 _broadcast < Args extends Array < unknown > > ( name : string , ...args : Args ) {
14901497 this . #assertReady( ) ;
14911498
1499+ console . log ( "broadcasting event" , {
1500+ name,
1501+ args,
1502+ actorId : this . id ,
1503+ subscriptions : this . #subscriptionIndex. size ,
1504+ connections : this . conns . size ,
1505+ } ) ;
14921506 this . inspector . emitter . emit ( "eventFired" , {
14931507 type : "broadcast" ,
14941508 eventName : name ,
0 commit comments