diff --git a/packages/ice/src/stun/protocol.ts b/packages/ice/src/stun/protocol.ts index e52473fa6..bef12b95d 100644 --- a/packages/ice/src/stun/protocol.ts +++ b/packages/ice/src/stun/protocol.ts @@ -118,6 +118,8 @@ export class StunProtocol implements Protocol { try { return await transaction.run(); + } catch (e) { + throw e; } finally { delete this.transactions[request.transactionIdHex]; } diff --git a/packages/ice/src/stun/transaction.ts b/packages/ice/src/stun/transaction.ts index c4eb25299..19021f8f4 100644 --- a/packages/ice/src/stun/transaction.ts +++ b/packages/ice/src/stun/transaction.ts @@ -40,6 +40,15 @@ export class Transaction { try { this.retry(); return await this.onResponse.asPromise(); + } catch (error) { + log( + "transaction run failed", + error, + this.protocol.type, + this.request.toJSON() + ); + + throw error; } finally { if (this.timeoutHandle) { clearTimeout(this.timeoutHandle); diff --git a/packages/ice/src/turn/protocol.ts b/packages/ice/src/turn/protocol.ts index c853d3f0e..3f413ebb2 100644 --- a/packages/ice/src/turn/protocol.ts +++ b/packages/ice/src/turn/protocol.ts @@ -63,6 +63,8 @@ class TurnTransport implements Protocol { try { return await transaction.run(); + } catch (e) { + throw e; } finally { delete this.turn.transactions[request.transactionIdHex]; } @@ -199,7 +201,7 @@ class TurnClient implements Protocol { } refresh = () => - new PCancelable(async (r, f, onCancel) => { + new PCancelable(async (_, f, onCancel) => { let run = true; onCancel(() => { run = false; @@ -235,6 +237,8 @@ class TurnClient implements Protocol { try { return await transaction.run(); + } catch (e) { + throw e; } finally { delete this.transactions[request.transactionIdHex]; } @@ -272,7 +276,7 @@ class TurnClient implements Protocol { .setAttribute("XOR-PEER-ADDRESS", addr); const [response] = await this.request(request, this.server); if (response.messageMethod !== methods.CHANNEL_BIND) { - throw new Error(); + throw new Error("should be CHANNEL_BIND"); } }