highland icon indicating copy to clipboard operation
highland copied to clipboard

Pushing nil asynchronously to short-circuit a stream cause deadlock

Open vqvu opened this issue 8 years ago • 0 comments

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.

vqvu avatar Oct 29 '16 21:10 vqvu