fix: catch errors during identify (#1138)

Sometimes identify can be started while we are shutting down (for
example) - we should just log these errors.
This commit is contained in:
Alex Potsides
2022-01-21 08:26:21 +00:00
committed by GitHub
parent a4bba35948
commit 12f1bb0aee

View File

@ -267,6 +267,7 @@ class IdentifyService {
* @returns {Promise<void>}
*/
async _handleIdentify ({ connection, stream }) {
try {
let publicKey = new Uint8Array(0)
if (this.peerId.pubKey) {
publicKey = this.peerId.pubKey.bytes
@ -285,7 +286,6 @@ class IdentifyService {
protocols
}).finish()
try {
await pipe(
[message],
lp.encode(),
@ -343,7 +343,11 @@ class IdentifyService {
}
// Update the protocols
try {
await this.peerStore.protoBook.set(id, message.protocols)
} catch (/** @type {any} */ err) {
log.error('received invalid protocols', err)
}
}
/**