Skip to content

fix: consolidate iterable closing #3218

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

achingbrain
Copy link
Member

@achingbrain achingbrain commented Jul 11, 2025

We have MultiaddrConnections and Streams, both of which have .source and .sink properties, can be aborted or closed gracefully by iterables ending or by explicitly invoking .close/.abort methods, and can be closed or partially closed by the remote end of the connection.

All Stream implementations extend AbstractStream which has let us concentrate the logic that controls these (many) closing criteria but the same is not true of MultiaddrConnections.

Where we have these we transform them to async iterables which may not suit the underlying transport.

Here we consolidate the common parts of MultiaddrConnections into an AbstractMultiaddrConnection, and consolidate the async iterable/closing parts of both MultiaddrConnections and Streams into a HalfCloseableDuplex abstract superclass.

This greatly simplifies the transport implementations and allows all transports to benefit from tests run on the super class and we can remove a few dependencies (it-ws, stream-to-it, etc).

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if necessary (this includes comments as well)
  • I have added tests that prove my fix is effective or that my feature works

We have `MultiaddrConnection`s and `Stream`s, both of which have
`.source` and `.sink` properties, can be aborted or closed gracefully
by iterables ending or explicitly.

All `Stream` implementations extend `AbstractStream` which has let
us concentrate the logic that controls these (many) closing criteria
but the same is not true of `MultiaddrConnection`s.

Where we have these we transform them to async iterables which may not
suit the underlying transport.

Here we consolidate the common parts of `MultiaddrConnection`s into an
`AbstractMultiaddrConnection`, and consolidate the async iterable/closing
parts of both `MultiaddrConnection`s and `Stream`s into a
`HalfCloseableDuplex` abstract superclass.

This greatly simplifies the transport implementations and allows all
transports to benefit from tests run on the super class.
@achingbrain
Copy link
Member Author

Refs: ipshipyard/roadmaps#22

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

Successfully merging this pull request may close these issues.

1 participant