File tree 3 files changed +35
-0
lines changed
3 files changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' livekit-client ' : patch
3
+ ---
4
+
5
+ Log warning if multiple tracks of the same source are published
Original file line number Diff line number Diff line change @@ -434,6 +434,23 @@ export default class LocalParticipant extends Participant {
434
434
if ( opts . source ) {
435
435
track . source = opts . source ;
436
436
}
437
+ const existingTrackOfSource = Array . from ( this . tracks . values ( ) ) . find (
438
+ ( publishedTrack ) => track instanceof LocalTrack && publishedTrack . source === track . source ,
439
+ ) ;
440
+ if ( existingTrackOfSource ) {
441
+ try {
442
+ // throw an Error in order to capture the stack trace
443
+ throw Error ( `publishing a second track with the same source: ${ track . source } ` ) ;
444
+ } catch ( e : unknown ) {
445
+ if ( e instanceof Error ) {
446
+ log . warn ( e . message , {
447
+ oldTrack : existingTrackOfSource ,
448
+ newTrack : track ,
449
+ trace : e . stack ,
450
+ } ) ;
451
+ }
452
+ }
453
+ }
437
454
if ( opts . stopMicTrackOnMute && track instanceof LocalAudioTrack ) {
438
455
track . stopOnMute = true ;
439
456
}
Original file line number Diff line number Diff line change @@ -220,6 +220,19 @@ export default class RemoteParticipant extends Participant {
220
220
// always emit events for new publications, Room will not forward them unless it's ready
221
221
newTracks . forEach ( ( publication ) => {
222
222
this . emit ( ParticipantEvent . TrackPublished , publication ) ;
223
+ const existingTrackOfSource = Array . from ( this . tracks . values ( ) ) . find (
224
+ ( publishedTrack ) => publishedTrack . source === publication . source ,
225
+ ) ;
226
+ if ( existingTrackOfSource ) {
227
+ log . warn (
228
+ `received a second track publication for ${ this . identity } with the same source: ${ publication . source } ` ,
229
+ {
230
+ oldTrack : existingTrackOfSource ,
231
+ newTrack : publication ,
232
+ participant : this ,
233
+ } ,
234
+ ) ;
235
+ }
223
236
} ) ;
224
237
225
238
// detect removed tracks
You can’t perform that action at this time.
0 commit comments