libp2p / js-libp2p

The JavaScript Implementation of libp2p networking stack.
https://libp2p.io
Other
2.27k stars 436 forks source link

fix: close connections after use #2520

Closed achingbrain closed 1 month ago

achingbrain commented 2 months ago

Historically we've not tried to close connections after they've been opened because we let the connection pruner do that when it's required.

This leads to high resource usage and requires the pruner to be able to select the best connections for pruning which without the context of their intended use is a guessing game.

A distinction is drawn between protocols that have a definite purpose (e.g. kad-dht) and "speculative" protocols that are run on newly opened connections for other purposes, e.g. identify, auto nat, etc.

For example if kad-dht opens a connection to send a message, we can close that connection if the only protocol running on it is identify.

Change checklist

achingbrain commented 1 month ago

Closing as the connection pruner now closes connections without streams first.