Skip to content
This repository was archived by the owner on Aug 11, 2021. It is now read-only.

Commit 24c2ad5

Browse files
rvaggothiym23
authored andcommitted
collect: respect stream pause / resume state
Without watching if a stream is already paused before calling pause(), collect() can conflict with other users of the stream who may be managing state, resulting in a premature collect(). This manifests in the fstream-npm and node-tar combination where fstream-npm manages state in readBundledLinks() at the same time collect() is processing the stream. collect() ends up running before fstream-npm has properly set up the _correct_ list of entries according to the ignore rules. When collect() gets to run before this is complete, fstream starts performing _read() operations on a non-filtered list, keeping track of entry index, then after it starts, fstream-npm inserts a new list of entries and the entry index is incorrect and can skip files. Fixes: npm/npm#5082 Credit: @rvagg Reviewed-By: @othiym23 PR-URL: #53
1 parent a67b90b commit 24c2ad5

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/collect.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ module.exports = collect
33
function collect (stream) {
44
if (stream._collected) return
55

6+
if (stream._paused) return stream.on('resume', collect.bind(null, stream))
7+
68
stream._collected = true
79
stream.pause()
810

0 commit comments

Comments
 (0)