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

Streams are never closed #164

Closed
achingbrain opened this issue May 14, 2023 · 2 comments · Fixed by #165
Closed

Streams are never closed #164

achingbrain opened this issue May 14, 2023 · 2 comments · Fixed by #165
Labels
bug Something isn't working released

Comments

@achingbrain
Copy link
Member

The following simple echo stream code does not work:

import all from 'it-all'

const stream = await connection.newStream(echo)
const input = new Array(5).fill(0).map(() => new Uint8Array(10))

const output = await pipe(
  input,
  stream,
  all
)
console.info('all done') // <- never reached

The reason is the internal _sink method merges the source stream with a "close write iterable" that waits for the closeWritePromise deferred promise to resolve. This is done in the finally block of the sink method.

This block is never reached because the this._sink call doesn't return - it's waiting for the closeWritePromise deferred promise to resolve which creates a deadlock.

@marcus-pousette
Copy link
Contributor

marcus-pousette commented May 15, 2023

Can a keepAliveTimeout help ? Perhaps not ideal, but there is no information that no more elements are going to propagate through.

achingbrain added a commit that referenced this issue May 17, 2023
Refactors the stream class in this module to use the abstract superclass from `@libp2p/interface-stream-muxer` as it handles all the various scenarios for closing streams which this module does not.

Fixes #164
github-actions bot pushed a commit that referenced this issue May 17, 2023
## [2.0.4](v2.0.3...v2.0.4) (2023-05-17)

### Bug Fixes

* use abstract stream class from muxer interface module ([#165](#165)) ([32f68de](32f68de)), closes [#164](#164)
@github-actions
Copy link

🎉 This issue has been resolved in version 2.0.4 🎉

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
bug Something isn't working released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants