Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: send data during graceful close. #73

Merged
merged 1 commit into from
Feb 7, 2024

Conversation

achingbrain
Copy link
Collaborator

@achingbrain achingbrain commented Feb 7, 2024

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 libp2p/js-libp2p#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'.

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 libp2p/js-libp2p#2398
pass.
@achingbrain achingbrain requested a review from a team as a code owner February 7, 2024 14:46
@wemeetagain wemeetagain merged commit f5d92da into master Feb 7, 2024
11 of 19 checks passed
achingbrain added a commit that referenced this pull request Feb 8, 2024
#73 was merged on red, this fixes the build
github-actions bot pushed a commit that referenced this pull request Feb 8, 2024
## [6.0.2](v6.0.1...v6.0.2) (2024-02-08)

### Bug Fixes

* send data during graceful close ([#75](#75)) ([f77b9ec](f77b9ec))
* send data during graceful close. ([#73](#73)) ([f5d92da](f5d92da))
Copy link

github-actions bot commented Feb 8, 2024

🎉 This PR is included in version 6.0.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants