-
-
Notifications
You must be signed in to change notification settings - Fork 916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding 'data' event handler breaks output #109
Comments
Thats because you dump all data to |
Hmm, I just tried to add a a through2 transform to my pipeline that just passes data through and I still go no output when using var MultiStream = require('multistream')
var through2 = require('through2')
var got = require('got')
var request = require('request')
var count = 0;
function factory (cb) {
if (count > 3) return cb(null, null)
count++
var stream = got.stream('https://www.random.org/integers/?num='+count+'&min=1&max=6&col=1&base=10&format=plain&rnd=new')
// var stream = request('https://www.random.org/integers/?num='+count+'&min=1&max=6&col=1&base=10&format=plain&rnd=new')
stream.pipe(through2(function (chunk, enc, callback) {
this.push(chunk)
callback()
}))
setTimeout(function () {
cb(null, stream)
}, 100)
}
MultiStream(factory).pipe(process.stdout); |
Try this: stream = stream.pipe(through2(function (chunk, enc, callback) {
this.push(chunk)
callback()
})) |
@floatdrop Thanks, that worked. It's odd that |
I'm using
multistream
to stream multi API pages through the same stream (as suggested in issue #108) but I've ran into an issue. The API returns an empty array for pages that exceed the dataset so I need to "peek" at the data in the stream to know if I've reached the end. Using the example under stephenplusplus/stream-faqs as reference, if I add astream.on('data', function() { ... })
, no output is piped toprocess.stdout
when usinggot.stream()
. The issue does not occur when using request.The text was updated successfully, but these errors were encountered: