question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

multistream not consuming entire stream due to race condition. reproduction included.

See original GitHub issue

I’m running into an issue where multistream doesn’t consume the entire stream. Not sure why. If you follow the instructions and run node multistream.js lots of times, you’ll see intermittent content length mismatches.

I included node passthrough.js to provide an example that never fails. multistream.js and passthrough.js are nearly identical, only difference being piping to multistream vs piping to a passthrough stream.

https://www.diffchecker.com/bi5wMRCW

Reproduction steps

$ git clone https://github.com/guanzo/multistream-debug
$ cd multistream-debug
$ npm i 

# Run 20+ times, no failures
$ node passthrough.js

# Run 20+ times, intermittent failures
$ node multistream.js

here’s what i’m seeing

Edit: I found this bug after seeing webtorrent make never ending requests due to an invalid torrentFile. create-torrent uses multistream, and whenever this bug occurs, an invalid torrentFile is returned. Webseed tries to verify a valid chunk against an invalid torrentFile’s chunk hash. The verification fails, so webtorrent retries endlessly.

Edit: $ node multistream.js works with multistream@3.0.0. This commit seems to be the problem.

https://github.com/feross/multistream/commit/0813df4cc0227b61ad24f314d4970b17d8b45941

Removing && this._drained fixes the bug. Thoughts?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
srolelcommented, Jun 9, 2020

I’m also seeing this, is the fix going to be published?

1reaction
johnsusekcommented, Dec 3, 2019

Can confirm #51 fixes this issue for me

Read more comments on GitHub >

github_iconTop Results From Across the Web

Race condition when ending a stream #40471 - nodejs/node
Here it looks like that the pipeline isn't unpiped AND we don't get an error. So the written data isn't consumed by the...
Read more >
Race condition of buffered C++ streams when calling fork
Is there a better solution to this problem? Like a function that flushes all buffered C++ streams? EDIT. A suggested solution was to...
Read more >
A River Runs Through It: A Multiple Streams Metaâ•'Review
This study uses content analysis of recent Multiple Streams Approach (MSA) research to determine the scope of MSA applications, examining the consistency, ...
Read more >
Rate Types for Stream Programs - ProQuest
abilities of shared-memory models (e.g. race conditions and atomicity violations), ... Not all stream labels or hierarchical box labels are included.
Read more >
[#KAFKA-6844] Race condition between StreamThread and ...
There can be a race condition where shut down is called on a ... a/streams/src/main/java/org/apache/kafka/streams/KafkaStreams.java
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found