libp2p / js-libp2p

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

fix: close MultiaddrConnection once #2478

Closed twoeths closed 3 months ago

twoeths commented 3 months ago

Title

Close MultiaddrConnection once

Description

Notes & open questions

this could fix #2477 see https://github.com/libp2p/js-libp2p/issues/2477#issuecomment-2049121628

Change checklist

twoeths commented 3 months ago

@achingbrain thanks for the suggestions, now I improved the test and it failed on main. I did a small modification on the maConn.abort() function not to destroy the socket if it's already destroyed to make sure the socket.destroy() is called once

this is all about maConn.close() being called multiple times and we want it to close once, this happens when socket.writableLength > 0 which is reflected in the test