libp2p / js-libp2p

The JavaScript Implementation of libp2p networking stack.
https://libp2p.github.io/js-libp2p/
Other
2.34k stars 447 forks source link

fix: only close stream if it is open #2823

Closed achingbrain closed 1 week ago

achingbrain commented 1 week ago

Adds a guard to the .close operation similar to the one on .abort that ensures we only close the stream if it is open.

The individual .closeRead/.closeWrite operations already guard on the read/write status of the stream so there's no functional change, we just avoid a bit more async work as those methods return promises.

Change checklist