Skip to content

Commit

Permalink
improve error handling for debugger
Browse files Browse the repository at this point in the history
  • Loading branch information
shinyoshiaki committed Nov 9, 2023
1 parent 2ab88a4 commit 42f1b53
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/ice/src/stun/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ export class StunProtocol implements Protocol {

try {
return await transaction.run();
} catch (e) {
throw e;
} finally {
delete this.transactions[request.transactionIdHex];
}
Expand Down
9 changes: 9 additions & 0 deletions packages/ice/src/stun/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 6 additions & 2 deletions packages/ice/src/turn/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class TurnTransport implements Protocol {

try {
return await transaction.run();
} catch (e) {
throw e;
} finally {
delete this.turn.transactions[request.transactionIdHex];
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -235,6 +237,8 @@ class TurnClient implements Protocol {

try {
return await transaction.run();
} catch (e) {
throw e;
} finally {
delete this.transactions[request.transactionIdHex];
}
Expand Down Expand Up @@ -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");
}
}

Expand Down

0 comments on commit 42f1b53

Please sign in to comment.