@@ -786,6 +786,7 @@ export class ActorInstance<
786786 state : CS ,
787787 driverId : string ,
788788 driverState : unknown ,
789+ subs : string [ ] | undefined ,
789790 authData : unknown ,
790791 ) : Promise < Conn < S , CP , CS , V , I , AD , DB > > {
791792 this . #assertReady( ) ;
@@ -814,6 +815,12 @@ export class ActorInstance<
814815 ) ;
815816 this . #connections. set ( conn . id , conn ) ;
816817
818+ if ( subs ) {
819+ for ( const sub of subs ) {
820+ this . #addSubscription( sub , conn , true ) ;
821+ }
822+ }
823+
817824 // Add to persistence & save immediately
818825 this . #persist. c . push ( persist ) ;
819826 this . saveState ( { immediate : true } ) ;
@@ -875,6 +882,7 @@ export class ActorInstance<
875882 return await this . executeAction ( ctx , name , args ) ;
876883 } ,
877884 onSubscribe : async ( eventName , conn ) => {
885+ console . log ( "subscribing to event" , { eventName, connId : conn . id } ) ;
878886 this . inspector . emitter . emit ( "eventFired" , {
879887 type : "subscribe" ,
880888 eventName,
@@ -1251,6 +1259,13 @@ export class ActorInstance<
12511259 _broadcast < Args extends Array < unknown > > ( name : string , ...args : Args ) {
12521260 this . #assertReady( ) ;
12531261
1262+ console . log ( "broadcasting event" , {
1263+ name,
1264+ args,
1265+ actorId : this . id ,
1266+ subscriptions : this . #subscriptionIndex. size ,
1267+ connections : this . conns . size ,
1268+ } ) ;
12541269 this . inspector . emitter . emit ( "eventFired" , {
12551270 type : "broadcast" ,
12561271 eventName : name ,
0 commit comments