Skip to content

Commit 32c176f

Browse files
committed
fix: pass abort signal to stream close
1 parent 12bcd86 commit 32c176f

File tree

1 file changed

+5
-4
lines changed
  • packages/kad-dht/src/routing-table

1 file changed

+5
-4
lines changed

packages/kad-dht/src/routing-table/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,20 +269,21 @@ export class RoutingTable extends TypedEventEmitter<RoutingTableEvents> implemen
269269
}, Message, options)
270270
const response = await pb.read(Message, options)
271271

272-
await pb.unwrap().close()
272+
await pb.unwrap().close(options)
273273

274274
if (response.type !== MessageType.PING) {
275275
throw new InvalidMessageError(`Incorrect message type received, expected PING got ${response.type}`)
276276
}
277277

278+
this.log('old contact %p ping ok', oldContact.peerId)
278279
return true
279280
} catch (err: any) {
280-
if (this.running && this.kb != null) {
281+
if (this.running) {
281282
// only evict peers if we are still running, otherwise we evict
282283
// when dialing is cancelled due to shutdown in progress
283-
this.log.error('could not ping peer %p', oldContact.peerId, err)
284+
this.log.error('could not ping peer %p - %e', oldContact.peerId, err)
284285
this.log('evicting old contact after ping failed %p', oldContact.peerId)
285-
this.kb.remove(oldContact.kadId)
286+
this.kb?.remove(oldContact.kadId)
286287
}
287288

288289
stream?.abort(err)

0 commit comments

Comments
 (0)