fix: dont drain source while drain in progress #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Misbehaving streams can end up calling drain multiple times while
a drain is in progress. This is bad news for pull streams as it
breaks the contract and you end up with weirdness like end of stream
events getting triggered before data event callbacks are fired.
While tracking this down I applied a similar fix to pull-file-reader
but that modules shouldn't have to guard against bad pullers.
Then I found pull-stream/pull-stream-to-stream#6
which deals with the same issue in pull-stream-to-steam (thanks @mmckegg!)
and recreated it here. The test on this PR is copied from there.
The gist is, as this module operates at the boundary of node-streams
to pull-streams, it should deal with bad node-stream behaviour to
avoid messing up connected pull-streams.
fixes: ipfs-inactive/js-ipfs-http-client#967
fixes: ipfs/ipfs-webui#1010