Closed AlimovSV closed 9 years ago
I can't reproduce it here, the merged stream emits end
just fine after handling source streams' errors.
@AlimovSV
Could you show us an example code to reproduce the error you ran into, and the error messages?
Closing issue as I also can't reproduce this.
Please re-open if the issue re-occurs.
Possibly related: wearefractal/vinyl-fs#51
That sounds more like https://github.com/grncdr/merge-stream/issues/14 which was just fixed.
Oh nice, thanks!
Don't thank me, @fixplz pointed me right at the problem :+1:
I am facing a similar issue
@elisechant make sure all of your merged streams are actually emitting an end
event. This issue usually happens when one or more of the merged streams don't actually end.
@UltCombo How might I emit an end event?
var gulp = require('gulp');
var mergeStream = require('merge-stream');
var del = require('del');
gulp.task('script', function() {
var merged = mergeStream();
merged.add(
gulp.src('src/one.js')
.on('end', function() { console.log('END MERGE'); })
.pipe(gulp.dest( 'dest' ))
);
return merged;
});
gulp.task('clean', function(cb) {
del([
'dest'
], cb);
});
gulp script
, prints 'END MERGE'gulp clean
, prints 'END MERGE'gulp clean
, prints 'END MERGE'That's odd, it looks like your gulpfile is okay. What's the issue you're experiencing?
@UltCombo my issue is that repeated calls to gulp clean
after executing gulp script
print END MERGE for ever more. My expectation is that the should have ended. Is there a workaround to stop the stream inside the task (unpipe?)? something like:
gulp.task('script', function() {
var merged = mergeStream();
merged.add(
gulp.src('src/one.js')
.on('end', function() { console.log('END MERGE'); })
.pipe(gulp.dest( 'dest' ))
);
// pseudo code
merged.process();
merged.end();
});
Sorry, I didn't quite understand. It looks like your simplified sample code is missing some key parts. It would be nice if you could describe what you're trying to achieve, post enough of your gulpfile to reproduce the issue and describe what's not going well. Perhaps this topic would be better fit for Stack Overflow.
Thanks @UltCombo. For the thread, to kill the process so it doesn't hang around after execution, this seems to be an ok workaround:
stream.add(
gulp.src('src/one.js')
.on('end', function() {
this.emit( 'unpipe' ); // remove the finished task from the stream
})
.pipe(gulp.dest( 'dest' ))
);
@elisechant could you please include a gulpfile that demonstrates the problem? The one you included above works fine for me.
When source stream throw error but has .on('error', function() {}) merged streams never end.