highland
highland copied to clipboard
Pushing nil asynchronously to short-circuit a stream cause deadlock
This code doesn't work. "done" is never printed.
_([1])
.consume(function (err, x, push, next) {
if (err) {
push(err);
next();
} else if (x === _.nil) {
push(null, _.nil);
} else {
setTimeout(function () {
push(null, _.nil);
}, 0);
}
})
.done(function () {
console.log('done');
});
Spotted when looking at #558.