mirror of
https://github.com/waku-org/js-waku.git
synced 2025-02-24 18:18:22 +00:00
fix: improve logging for connection manager (#1303)
* merge: master * fix: CI * use: js script instead of shell script to run precheck and mocha * improve logging when dial fails * use hashmap for errors instead of redeclaring variable
This commit is contained in:
parent
cc0b375018
commit
f4e31019e1
@ -19,6 +19,7 @@ export class ConnectionManager {
|
|||||||
private options: ConnectionManagerOptions;
|
private options: ConnectionManagerOptions;
|
||||||
private libp2pComponents: Libp2p;
|
private libp2pComponents: Libp2p;
|
||||||
private dialAttemptsForPeer: Map<string, number> = new Map();
|
private dialAttemptsForPeer: Map<string, number> = new Map();
|
||||||
|
private dialErrorsForPeer: Map<string, any> = new Map();
|
||||||
|
|
||||||
public static create(
|
public static create(
|
||||||
peerId: string,
|
peerId: string,
|
||||||
@ -102,9 +103,10 @@ export class ConnectionManager {
|
|||||||
|
|
||||||
this.dialAttemptsForPeer.delete(peerId.toString());
|
this.dialAttemptsForPeer.delete(peerId.toString());
|
||||||
return;
|
return;
|
||||||
} catch (error) {
|
} catch (error: any) {
|
||||||
log(`
|
this.dialErrorsForPeer.set(peerId.toString(), error);
|
||||||
Error dialing peer ${peerId.toString()}`);
|
log(`Error dialing peer ${peerId.toString()} - ${error.errors}`);
|
||||||
|
|
||||||
dialAttempt = this.dialAttemptsForPeer.get(peerId.toString()) ?? 1;
|
dialAttempt = this.dialAttemptsForPeer.get(peerId.toString()) ?? 1;
|
||||||
this.dialAttemptsForPeer.set(peerId.toString(), dialAttempt + 1);
|
this.dialAttemptsForPeer.set(peerId.toString(), dialAttempt + 1);
|
||||||
|
|
||||||
@ -115,7 +117,13 @@ export class ConnectionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
log(`Deleting undialable peer ${peerId.toString()} from peer store`);
|
log(
|
||||||
|
`Deleting undialable peer ${peerId.toString()} from peer store. Error: ${JSON.stringify(
|
||||||
|
this.dialErrorsForPeer.get(peerId.toString()).errors[0]
|
||||||
|
)}
|
||||||
|
}`
|
||||||
|
);
|
||||||
|
this.dialErrorsForPeer.delete(peerId.toString());
|
||||||
return await this.libp2pComponents.peerStore.delete(peerId);
|
return await this.libp2pComponents.peerStore.delete(peerId);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw `Error deleting undialable peer ${peerId.toString()} from peer store - ${error}`;
|
throw `Error deleting undialable peer ${peerId.toString()} from peer store - ${error}`;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user