dominictarr / through

simple way to create a ReadableWritable stream that works
Other
669 stars 64 forks source link

stream must be close properly #45

Closed win-t closed 7 years ago

win-t commented 7 years ago

Hi, the spec say nothing about end method must call this.queue(null) or this.emit('end') without that, the stream will keep open,

I know this after play around with gulpfile

const gulp = require('gulp');
const through = require('through');

gulp.task('lala', function() {
  return gulp.src([])
    .pipe(through(function() {}, function() {}));
})

the output of that task will be

[12:57:39] Using gulpfile ~/asdf/gulpfile.js
[12:57:39] Starting 'lala'...

there is no Finished 'lala' after xx ms line, that mean the stream was never closed properly

I think the default behavior should close the stream whenever the user explicitly call this.queue(null) or this.emit('end') or not at all. Because the spec said that end callback is optional, and never say the requirement when one use it

Another solution, just update the docs

win-t commented 7 years ago

hmm, I just know that this package is just utilities for Stream1 API, but that version of Nodejs is already dead, so I think this package is not necessary anymore, and we should avoid using this package