ChainSafe / js-libp2p-yamux

Typescript implementation of Yamux
Other
10 stars 8 forks source link

fix: send data during graceful close. #73

Closed achingbrain closed 4 months ago

achingbrain commented 4 months ago

When a stream is closed gracefully, it's status goes from 'open' to 'closing' then to either 'closed', 'aborted' or 'reset'.

While it's 'closing' we should still try to send any queued data, this can be aborted by calling .abort on the stream or by the signal passed to .close firing the 'abort' event.

This change makes the tests added in https://github.com/libp2p/js-libp2p/pull/2398 pass, in particular the one where we use it-byte-stream and write data larger than the send capacity. When this happens we wait for the remote to signal to accept more data, during which time the stream is closed gracefully and the data ends up being truncated as we stop sending when this.status is no longer 'open'.

github-actions[bot] commented 4 months ago

:tada: This PR is included in version 6.0.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: