diff --git a/nodejs-readdirp-pause.patch b/nodejs-readdirp-pause.patch new file mode 100644 index 0000000..86dd7ef --- /dev/null +++ b/nodejs-readdirp-pause.patch @@ -0,0 +1,45 @@ +commit 4a11a8e56af9afc72bc9ac8c8981c1693810fbfc +Author: Tom Hughes +Date: Thu Dec 31 12:18:02 2015 +0000 + + Wait until the next tick to pause the stream + + Registering handlers on a stream with `on` causes resume to be + called, but only on the next tick. + + This leads to a race condition where the pause can happen before + that delayed resume, which then resumes the stream earlier than we + were expecting. + +diff --git a/test/readdirp-stream.js b/test/readdirp-stream.js +index b05688d..5fa28cb 100644 +--- a/test/readdirp-stream.js ++++ b/test/readdirp-stream.js +@@ -252,16 +252,19 @@ test('\napi separately', function (t) { + t.equals(data, processedData, 'emits the buffered data'); + t.ok(resumed, 'emits data only after it was resumed'); + }) +- .pause() + +- api.processEntry(processedData); +- api.handleError(nonfatalError); +- api.handleFatalError(fatalError); ++ process.nextTick(function() { ++ api.stream.pause(); ++ ++ api.processEntry(processedData); ++ api.handleError(nonfatalError); ++ api.handleFatalError(fatalError); + +- setTimeout(function () { +- resumed = true; +- api.stream.resume(); +- }, 1) ++ setTimeout(function () { ++ resumed = true; ++ api.stream.resume(); ++ }, 1) ++ }) + }) + + diff --git a/nodejs-readdirp.spec b/nodejs-readdirp.spec index 8f97d24..2bd52c8 100644 --- a/nodejs-readdirp.spec +++ b/nodejs-readdirp.spec @@ -15,6 +15,8 @@ Source0: https://registry.npmjs.org/readdirp/-/readdirp-%{version}.tgz # version control repository. Source1: tests-v%{version}.tar.bz2 Source10: dl-tests.sh +# +Patch0: nodejs-readdirp-pause.patch BuildArch: noarch %if 0%{?fedora} >= 19 @@ -42,8 +44,11 @@ BuildRequires: npm(through2) # The NPM tarball is missing some files within test/ rm -rf test/ %setup -q -T -D -a 1 -n package +# Apply patches +%patch0 -p1 # Remove executable bit. find . -type f -exec chmod -x '{}' \; +# Fix dependencies %nodejs_fixdep minimatch "^0.2.12"