stephenlacy / gulp-stylus

Stylus plugin for gulp
MIT License
223 stars 60 forks source link

Avoid calling stream callback twice #140

Closed mogelbrod closed 9 years ago

mogelbrod commented 9 years ago

This PR prevents the through2 stream callback from being called more than once if an error is thrown synchronously during the cb function invocation (thus throwing the actual error in favor of a generic no writecb in Transform class error).

mogelbrod commented 9 years ago

Not 100% sure about the necessity for this change, but I was having problems debugging a gulp task which kept throwing no writecb in Transform class without any additional information and this change helped me determine the real error.

stephenlacy commented 9 years ago

A return cb() will exit the stream, it won't continue. If the error is called twice (no writecb in Transform class) it is due to the error thrown in the stream continuing through either from a prior plugin or a following plugin. It's not the best idea to throw errors, as passing it back through the gulp stream will allow an .on('error', function(e)) {} to catch all the errors instead of just throwing to the log and stopping the task.

Thanks for contributing though!