mirror of https://github.com/status-im/js-waku.git
chore: add error handling for an uncaught dial attempt (#1660)
This commit is contained in:
parent
d39d4507ef
commit
e6527e9ab1
|
@ -226,16 +226,24 @@ export class ConnectionManager
|
||||||
try {
|
try {
|
||||||
const error = this.dialErrorsForPeer.get(peerId.toString());
|
const error = this.dialErrorsForPeer.get(peerId.toString());
|
||||||
|
|
||||||
let errorMessage;
|
if (error) {
|
||||||
if (error instanceof AggregateError) {
|
let errorMessage;
|
||||||
errorMessage = JSON.stringify(error.errors[0]);
|
if (error instanceof AggregateError) {
|
||||||
} else {
|
if (!error.errors) {
|
||||||
errorMessage = error.message;
|
log(`No errors array found for AggregateError`);
|
||||||
}
|
} else if (error.errors.length === 0) {
|
||||||
|
log(`Errors array is empty for AggregateError`);
|
||||||
|
} else {
|
||||||
|
errorMessage = JSON.stringify(error.errors[0]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
errorMessage = error.message;
|
||||||
|
}
|
||||||
|
|
||||||
log(
|
log(
|
||||||
`Deleting undialable peer ${peerId.toString()} from peer store. Error: ${errorMessage}`
|
`Deleting undialable peer ${peerId.toString()} from peer store. Error: ${errorMessage}`
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
this.dialErrorsForPeer.delete(peerId.toString());
|
this.dialErrorsForPeer.delete(peerId.toString());
|
||||||
await this.libp2p.peerStore.delete(peerId);
|
await this.libp2p.peerStore.delete(peerId);
|
||||||
|
@ -314,7 +322,7 @@ export class ConnectionManager
|
||||||
if (!(await this.shouldDialPeer(peerId))) return;
|
if (!(await this.shouldDialPeer(peerId))) return;
|
||||||
|
|
||||||
this.dialPeer(peerId).catch((err) => {
|
this.dialPeer(peerId).catch((err) => {
|
||||||
throw `Error dialing peer ${peerId.toString()} : ${err}`;
|
log(`Error dialing peer ${peerId.toString()} : ${err}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue