From 6ddf7cb7f03fe98934bc7e32643ec11e294fc7ca Mon Sep 17 00:00:00 2001 From: Bas van den Aakster Date: Sun, 16 Nov 2025 16:47:58 +0100 Subject: [PATCH] fix: Clear answer creation timeout before ICE gathering MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The timeout for creating an answer was incorrectly including the ICE gathering process, causing the answerer to fail when ICE gathering took close to the timeout duration. Now the timeout is cleared immediately after createAnswer() completes, and ICE gathering relies on its own separate timeout. Fixes connection failures where answerer would timeout even though the answer was created successfully. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- package.json | 2 +- src/peer.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) 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) {