@matterbridge/core 3.11.2-dev-20261102-e93031b → 3.11.2-dev-20261102-10dec49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -68,6 +68,8 @@ export declare class WeriftWebRtcSession {
68
68
  applyAnswer(answerSdp: string): Promise<void>;
69
69
  addIceCandidate(candidate: string, sdpMid: string | null, sdpMLineIndex: number | null): Promise<void>;
70
70
  private closing;
71
+ private descriptionOperations;
72
+ private withDescriptionOperation;
71
73
  private logDtlsTransportStateChanges;
72
74
  private logDiagnosticsSnapshot;
73
75
  close(): Promise<void>;
@@ -515,7 +515,7 @@ export class WeriftWebRtcSession {
515
515
  if (options.offerAudio)
516
516
  this.peerConnection.addTransceiver('audio', { direction: 'sendonly' });
517
517
  const offer = await this.peerConnection.createOffer();
518
- await this.peerConnection.setLocalDescription(offer);
518
+ await this.withDescriptionOperation(async () => this.peerConnection.setLocalDescription(offer));
519
519
  const sdp = this.peerConnection.localDescription.sdp;
520
520
  this.log.info(`Created local SDP offer (${this.summarizeSdp(sdp)})`);
521
521
  this.logDtlsTransportStateChanges();
@@ -524,7 +524,7 @@ export class WeriftWebRtcSession {
524
524
  async createAnswer(offerSdp, overrides) {
525
525
  this.applyOptionOverrides(overrides);
526
526
  this.log.debug(`CreateAnswer requested for remote offer (${this.summarizeSdp(offerSdp)}, videoResolution=${this.options.videoResolution ?? 'undefined'})`);
527
- await this.peerConnection.setRemoteDescription({ type: 'offer', sdp: offerSdp });
527
+ await this.withDescriptionOperation(async () => this.peerConnection.setRemoteDescription({ type: 'offer', sdp: offerSdp }));
528
528
  const hasVideoTransceiver = this.peerConnection.getTransceivers().some((transceiver) => transceiver.kind === 'video');
529
529
  this.log.debug(`Remote offer created video transceiver: ${hasVideoTransceiver}`);
530
530
  if (hasVideoTransceiver) {
@@ -553,7 +553,7 @@ export class WeriftWebRtcSession {
553
553
  transceiver.setDirection('sendonly');
554
554
  }
555
555
  const answer = await this.peerConnection.createAnswer();
556
- await this.peerConnection.setLocalDescription(answer);
556
+ await this.withDescriptionOperation(async () => this.peerConnection.setLocalDescription(answer));
557
557
  const sdp = this.peerConnection.localDescription.sdp;
558
558
  this.log.info(`Created local SDP answer (${this.summarizeSdp(sdp)})`);
559
559
  this.logDtlsTransportStateChanges();
@@ -561,7 +561,7 @@ export class WeriftWebRtcSession {
561
561
  }
562
562
  async applyAnswer(answerSdp) {
563
563
  this.log.debug(`ApplyAnswer requested (${this.summarizeSdp(answerSdp)})`);
564
- await this.peerConnection.setRemoteDescription({ type: 'answer', sdp: answerSdp });
564
+ await this.withDescriptionOperation(async () => this.peerConnection.setRemoteDescription({ type: 'answer', sdp: answerSdp }));
565
565
  this.log.info(`Remote SDP answer applied (signalingState=${this.peerConnection.signalingState})`);
566
566
  this.logDtlsTransportStateChanges();
567
567
  }
@@ -570,6 +570,16 @@ export class WeriftWebRtcSession {
570
570
  await this.peerConnection.addIceCandidate({ candidate, sdpMid: sdpMid ?? undefined, sdpMLineIndex: sdpMLineIndex ?? undefined });
571
571
  }
572
572
  closing = false;
573
+ descriptionOperations = 0;
574
+ async withDescriptionOperation(operation) {
575
+ this.descriptionOperations++;
576
+ try {
577
+ return await operation();
578
+ }
579
+ finally {
580
+ this.descriptionOperations--;
581
+ }
582
+ }
573
583
  logDtlsTransportStateChanges() {
574
584
  for (const transport of this.peerConnection.dtlsTransports) {
575
585
  if (this.dtlsTransportsWithStateLogging.has(transport))
@@ -578,6 +588,10 @@ export class WeriftWebRtcSession {
578
588
  transport.onStateChange.subscribe((state) => {
579
589
  this.log.info(`DTLS transport state: ${state}`);
580
590
  if ((state === 'closed' || state === 'failed') && !this.closing) {
591
+ if (this.descriptionOperations > 0 || !this.peerConnection.dtlsTransports.includes(transport)) {
592
+ this.log.debug(`Ignoring DTLS transport state ${state} for session ${this.webRtcSessionId}: transport replaced or retired by the negotiation`);
593
+ return;
594
+ }
581
595
  this.log.info(`Closing session ${this.webRtcSessionId}: DTLS transport reached ${state}`);
582
596
  fireAndForget(this.close(), this.log, `Failed to auto-close session ${this.webRtcSessionId} after DTLS transport reached ${state}`);
583
597
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matterbridge/core",
3
- "version": "3.11.2-dev-20261102-e93031b",
3
+ "version": "3.11.2-dev-20261102-10dec49",
4
4
  "description": "Matterbridge core library",
5
5
  "author": "https://github.com/Luligu",
6
6
  "homepage": "https://matterbridge.io/",
@@ -136,17 +136,17 @@
136
136
  },
137
137
  "dependencies": {
138
138
  "@matter/main": "0.18.0",
139
- "@matterbridge/dgram": "3.11.2-dev-20261102-e93031b",
140
- "@matterbridge/thread": "3.11.2-dev-20261102-e93031b",
141
- "@matterbridge/types": "3.11.2-dev-20261102-e93031b",
142
- "@matterbridge/utils": "3.11.2-dev-20261102-e93031b",
139
+ "@matterbridge/dgram": "3.11.2-dev-20261102-10dec49",
140
+ "@matterbridge/thread": "3.11.2-dev-20261102-10dec49",
141
+ "@matterbridge/types": "3.11.2-dev-20261102-10dec49",
142
+ "@matterbridge/utils": "3.11.2-dev-20261102-10dec49",
143
143
  "escape-html": "1.0.3",
144
144
  "express": "5.3.0",
145
145
  "express-rate-limit": "8.7.2",
146
146
  "multer": "2.5.0",
147
147
  "node-ansi-logger": "3.3.1",
148
148
  "node-persist-manager": "2.1.1",
149
- "werift": "0.25.2",
150
- "ws": "8.22.0"
149
+ "werift": "0.26.0",
150
+ "ws": "8.22.1"
151
151
  }
152
152
  }