Skip to content

Commit e9babb1

Browse files
authored
Clean pending initial offer when close pc (#1897)
1 parent 6c7ebc0 commit e9babb1

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/room/PCTransport.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export default class PCTransport extends EventEmitter {
165165
this.remoteStereoMids = stereoMids;
166166
this.remoteNackMids = nackMids;
167167
} else if (sd.type === 'answer') {
168-
if (this.pendingInitialOffer) {
168+
if (this.pendingInitialOffer && this._pc) {
169169
const initialOffer = this.pendingInitialOffer;
170170
this.pendingInitialOffer = undefined;
171171
const sdpParsed = parse(initialOffer.sdp ?? '');
@@ -523,6 +523,7 @@ export default class PCTransport extends EventEmitter {
523523
if (!this._pc) {
524524
return;
525525
}
526+
this.pendingInitialOffer = undefined;
526527
this._pc.close();
527528
this._pc.onconnectionstatechange = null;
528529
this._pc.oniceconnectionstatechange = null;
@@ -565,9 +566,9 @@ export default class PCTransport extends EventEmitter {
565566

566567
try {
567568
if (remote) {
568-
await this.pc.setRemoteDescription(sd);
569+
await this._pc?.setRemoteDescription(sd);
569570
} else {
570-
await this.pc.setLocalDescription(sd);
571+
await this._pc?.setLocalDescription(sd);
571572
}
572573
} catch (e) {
573574
let msg = 'unknown error';

0 commit comments

Comments
 (0)