Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

feat!: add stream muxer close #254

Merged
merged 1 commit into from
Jun 22, 2022
Merged

Conversation

wemeetagain
Copy link
Member

BREAKING CHANGE: StreamMuxer now has a close method

Resolves #249

@wemeetagain wemeetagain force-pushed the feat/stream-muxer-close branch 4 times, most recently from 5b7f6bc to fb70709 Compare June 20, 2022 19:01
this.streams.forEach(s => s.abort(err))
}
this.closeController.abort()
this.input.end(err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling this.input.end(err) may not be necessary here.

I think what will happen is calling this.closeController.abort() will cause the pipe in sink to throw, the error will be caught and passed to this.input.end on line 316.

Ending the input should then cause the connection to close? It's not clear what use a muxed connection with a closed muxer is, so that's probably good.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I think the only big difference is that by calling this.input.end(err) explicitly, the error is passed to the source.
If we rely on the pipe in sink to throw, the error that the source will get will be some generic "aborted" error.

Not sure which is the desired behavior, or that either behavior matters to the interface.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this.input.end(err) is better - it's not async and the received error is more useful than 'aborted'.

@wemeetagain wemeetagain force-pushed the feat/stream-muxer-close branch 2 times, most recently from f184744 to 619fae7 Compare June 21, 2022 18:27
BREAKING CHANGE: StreamMuxer now has a `close` method
@wemeetagain wemeetagain merged commit d1f511e into master Jun 22, 2022
@wemeetagain wemeetagain deleted the feat/stream-muxer-close branch June 22, 2022 13:56
github-actions bot pushed a commit that referenced this pull request Jun 22, 2022
## [@libp2p/interface-stream-muxer-v2.0.0](https:/libp2p/js-libp2p-interfaces/compare/@libp2p/interface-stream-muxer-v1.1.0...@libp2p/interface-stream-muxer-v2.0.0) (2022-06-22)

### ⚠ BREAKING CHANGES

* StreamMuxer now has a `close` method

### Features

* add stream muxer close ([#254](#254)) ([d1f511e](d1f511e))
@github-actions
Copy link

🎉 This PR is included in version @libp2p/interface-stream-muxer-v2.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

if (this.closeController.signal.aborted) return
this.log('closing muxed streams')

if (err == null) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (err) instead to catch undefined ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's a linter rule against implicitly coersing to a boolean.
foo == null does the same tho, will match on both null and undefined.

github-actions bot pushed a commit that referenced this pull request Jun 24, 2022
## [@libp2p/interface-stream-muxer-compliance-tests-v3.0.0](https:/libp2p/js-libp2p-interfaces/compare/@libp2p/interface-stream-muxer-compliance-tests-v2.1.0...@libp2p/interface-stream-muxer-compliance-tests-v3.0.0) (2022-06-24)

### ⚠ BREAKING CHANGES

* StreamMuxer now has a `close` method

### Features

* add stream muxer close ([#254](#254)) ([d1f511e](d1f511e))

### Trivial Changes

* update sibling dependencies [skip ci] ([c522241](c522241))
@github-actions
Copy link

🎉 This PR is included in version @libp2p/interface-stream-muxer-compliance-tests-v3.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

github-actions bot pushed a commit that referenced this pull request Jun 24, 2022
## [@libp2p/interface-mocks-v3.0.0](https:/libp2p/js-libp2p-interfaces/compare/@libp2p/interface-mocks-v2.1.0...@libp2p/interface-mocks-v3.0.0) (2022-06-24)

### ⚠ BREAKING CHANGES

* StreamMuxer now has a `close` method

### Features

* add stream muxer close ([#254](#254)) ([d1f511e](d1f511e))

### Trivial Changes

* update sibling dependencies [skip ci] ([7f7fb67](7f7fb67))
* update sibling dependencies [skip ci] ([c522241](c522241))
@github-actions
Copy link

🎉 This PR is included in version @libp2p/interface-mocks-v3.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

Add muxer.close() to StreamMuxer
3 participants