fix: Clear answer creation timeout before ICE gathering

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 <noreply@anthropic.com>
This commit is contained in:
2025-11-16 16:47:58 +01:00
parent 35ce051a26
commit 6ddf7cb7f0
2 changed files with 7 additions and 3 deletions

View File

@@ -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",

View File

@@ -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) {