gulp-useref icon indicating copy to clipboard operation
gulp-useref copied to clipboard

Unhandled stream error in transformStream

Open youngboy opened this issue 9 years ago • 1 comments

From reading code example, it is using lazypipe as transformStream, but lazypipe can only attach error listener after it is initialized. So I guess there is no way to capture transformStream's error in our gulpfile.

My situation is running a watch task for babel transformStream, once babel throw error a syntax error, it will exit the watch process, here is a short code example:

  return gulp.src('./www/index.html')
    .pipe(plugins.useref(
      {},
      lazypipe().pipe(function () {
        return plugins.babel()
          .on('error', onError);
        });
    ));

In this case my onError won't end the transformStream as I wish. My question is if we can add on('error') on those transformStream by default to emit('end') and let gulpfile handling the error itself. I would also appreciate any suggestion for how to handle this?

Thanks.

youngboy avatar Jan 13 '16 04:01 youngboy

  1. You don't have to use lazypipe, just use a function, like
useref({}, function(name) { return babel() })
  1. What do you do on error? Why not emit end in onError?

iliakan avatar Jan 19 '16 07:01 iliakan