Skip to content

Commit 3e12c85

Browse files
authored
fix: ensure offerId is only increased when offers are actually generated (#1585)
1 parent 04ea549 commit 3e12c85

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

.changeset/hip-spiders-return.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"livekit-client": patch
3+
---
4+
5+
fix: ensure offerId is only increased when offers are actually generated

src/room/PCTransport.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,6 @@ export default class PCTransport extends EventEmitter {
258258
const unlock = await this.offerLock.lock();
259259

260260
try {
261-
// increase the offer id at the start to ensure the offer is always > 0 so that we can use 0 as a default value for legacy behavior
262-
const offerId = this.latestOfferId + 1;
263-
this.latestOfferId = offerId;
264-
265261
if (this.onOffer === undefined) {
266262
return;
267263
}
@@ -290,6 +286,9 @@ export default class PCTransport extends EventEmitter {
290286

291287
// actually negotiate
292288
this.log.debug('starting to negotiate', this.logContext);
289+
// increase the offer id at the start to ensure the offer is always > 0 so that we can use 0 as a default value for legacy behavior
290+
const offerId = this.latestOfferId + 1;
291+
this.latestOfferId = offerId;
293292
const offer = await this.pc.createOffer(options);
294293
this.log.debug('original offer', { sdp: offer.sdp, ...this.logContext });
295294

0 commit comments

Comments
 (0)