fix: do not add abort signals to "useless" addresses #913
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Node warns of a possible memory leak thanks o added event listeners on abortSignal:
This started to happen when we start supporting
dnsaddr
resolution andjs-ipfs
started using bootstrap nodes with such addresses. Once thesednsaddr
records are resolved, we get a large list of multiaddrs for the given peer, where several addresses are not relevant for JS libp2p dialer as we do not support transports for them (quic).Despite having several useless addresses, during the dial flow we only checked if we have any transport to dial a peer on the
transport-manager
layer, which essentially means we are adding unnecessary event listeneres and creating unnecessary promises to be resolved for each of the addresses that will simply be rejected further on the stack.This PR fixes the above issue by simply filtering out in the beginning of the dial flow the addresses that will not be useful.
Closes #900