@@ -917,6 +917,7 @@ export class ActorInstance<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
917
917
state : CS ,
918
918
driverId : ConnectionDriver ,
919
919
driverState : unknown ,
920
+ subscriptions : string [ ] ,
920
921
authData : unknown ,
921
922
) : Promise < Conn < S , CP , CS , V , I , DB > > {
922
923
this . #assertReady( ) ;
@@ -950,6 +951,11 @@ export class ActorInstance<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
950
951
//
951
952
// Do this immediately after adding connection & before any async logic in order to avoid race conditions with sleep timeouts
952
953
this . #resetSleepTimer( ) ;
954
+ if ( subscriptions ) {
955
+ for ( const sub of subscriptions ) {
956
+ this . #addSubscription( sub , conn , true ) ;
957
+ }
958
+ }
953
959
954
960
// Add to persistence & save immediately
955
961
this . #persist. connections . push ( persist ) ;
@@ -1017,6 +1023,7 @@ export class ActorInstance<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
1017
1023
return await this . executeAction ( ctx , name , args ) ;
1018
1024
} ,
1019
1025
onSubscribe : async ( eventName , conn ) => {
1026
+ console . log ( "subscribing to event" , { eventName, connId : conn . id } ) ;
1020
1027
this . inspector . emitter . emit ( "eventFired" , {
1021
1028
type : "subscribe" ,
1022
1029
eventName,
@@ -1489,6 +1496,13 @@ export class ActorInstance<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
1489
1496
_broadcast < Args extends Array < unknown > > ( name : string , ...args : Args ) {
1490
1497
this . #assertReady( ) ;
1491
1498
1499
+ console . log ( "broadcasting event" , {
1500
+ name,
1501
+ args,
1502
+ actorId : this . id ,
1503
+ subscriptions : this . #subscriptionIndex. size ,
1504
+ connections : this . conns . size ,
1505
+ } ) ;
1492
1506
this . inspector . emitter . emit ( "eventFired" , {
1493
1507
type : "broadcast" ,
1494
1508
eventName : name ,
0 commit comments