diff --git a/package.json b/package.json index 120512f..628c4eb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@xtr-dev/rondevu-client", - "version": "0.5.0", + "version": "0.5.1", "description": "TypeScript client for Rondevu topic-based peer discovery and signaling server", "type": "module", "main": "dist/index.js", diff --git a/src/peer.ts b/src/peer.ts index b29b5d2..714a711 100644 --- a/src/peer.ts +++ b/src/peer.ts @@ -330,6 +330,12 @@ class AnsweringState extends PeerState { const answer = await this.peer.pc.createAnswer(); await this.peer.pc.setLocalDescription(answer); + // Clear the answer creation timeout - ICE gathering has its own timeout + if (this.timeout) { + clearTimeout(this.timeout); + this.timeout = undefined; + } + // Wait for ICE gathering const iceTimeout = options.timeouts?.iceGathering || 10000; await this.waitForIceGathering(iceTimeout); @@ -357,8 +363,6 @@ class AnsweringState extends PeerState { } }; - if (this.timeout) clearTimeout(this.timeout); - // Transition to exchanging ICE this.peer.setState(new ExchangingIceState(this.peer, offerId, options)); } catch (error) {