File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -382,14 +382,15 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
382382 if ( participant ) {
383383 this . remoteParticipants . delete ( participant . identity ) ;
384384 participant . info . disconnectReason = ev . value . disconnectReason ;
385+ // Emit before disposing so listeners can still access trackPublications.
386+ this . emit ( RoomEvent . ParticipantDisconnected , participant ) ;
385387 // Dispose each track publication's FfiHandle to prevent FD leaks.
386388 // Without this, rapid participant disconnections accumulate undisposed
387389 // native handles since nothing else triggers their cleanup.
388390 for ( const [ , publication ] of participant . trackPublications ) {
389391 publication . ffiHandle . dispose ( ) ;
390392 }
391393 participant . trackPublications . clear ( ) ;
392- this . emit ( RoomEvent . ParticipantDisconnected , participant ) ;
393394 } else {
394395 log . warn ( `RoomEvent.ParticipantDisconnected: Could not find participant` ) ;
395396 }
You can’t perform that action at this time.
0 commit comments