From 32c176fd53e9aa953885398ddc67387e46875b85 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Mon, 30 Sep 2024 17:12:10 +0100 Subject: [PATCH] fix: pass abort signal to stream close --- packages/kad-dht/src/routing-table/index.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/kad-dht/src/routing-table/index.ts b/packages/kad-dht/src/routing-table/index.ts index 92d0625d71..7d5056f6b5 100644 --- a/packages/kad-dht/src/routing-table/index.ts +++ b/packages/kad-dht/src/routing-table/index.ts @@ -269,20 +269,21 @@ export class RoutingTable extends TypedEventEmitter implemen }, Message, options) const response = await pb.read(Message, options) - await pb.unwrap().close() + await pb.unwrap().close(options) if (response.type !== MessageType.PING) { throw new InvalidMessageError(`Incorrect message type received, expected PING got ${response.type}`) } + this.log('old contact %p ping ok', oldContact.peerId) return true } catch (err: any) { - if (this.running && this.kb != null) { + if (this.running) { // only evict peers if we are still running, otherwise we evict // when dialing is cancelled due to shutdown in progress - this.log.error('could not ping peer %p', oldContact.peerId, err) + this.log.error('could not ping peer %p - %e', oldContact.peerId, err) this.log('evicting old contact after ping failed %p', oldContact.peerId) - this.kb.remove(oldContact.kadId) + this.kb?.remove(oldContact.kadId) } stream?.abort(err)