Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plumber failing to continue after async error #34

Open
rimassa opened this issue May 27, 2015 · 1 comment
Open

Plumber failing to continue after async error #34

rimassa opened this issue May 27, 2015 · 1 comment

Comments

@rimassa
Copy link

rimassa commented May 27, 2015

Hello!

I wrote three simplified scenarios to try to understand why plumber is failing to keep the stream flow after some error ocurred on my plugin (which transforms vinyl files asynchronously).

I'm using node v0.12.2 and I'm running my tests with node gulp.js

This is the first case:
https://gist.github.com/rimassa/229af1fe328bff31e817
It's a simple pipeline, which retrieves files from a instance of FileSource, passes them through a plugin (which just re-emitts the same files after 100 milliseconds and stores them in a instance of FileDest.
Plumber is connected right after the FileSource. My plugins does not emit any errors and everything works perfectly, as you can see on "output.log".

This is the second scenario:
https://gist.github.com/rimassa/62ce1f9d2573096d549a
This code is almost identical to the previous one, except for my plugin. It emits an error on the fifth file, by calling cb(new Error(...)). As you may notice on the file 'output.log', plumber is not able to recover the stream flow: the processing stops at the fifth file.

I was able to make this work in the third case:
https://gist.github.com/rimassa/dfa57285d3898c9fe0c6
I've just replaced cb(new Error(...)) with this.emit('error', new Error(...)); cb(). Now plumber seems to handle the error and resume the stream, processing the next five files.

Why does it happens? Is it ok to use the workaround I did on the last scenario?

Cheers
Ricardo

@floatdrop
Copy link
Owner

Wild guess - in second example gulp-plumber actually catches error, but still Transform stream is considered itself broken so no more further piping happening. You can dig inside Transform and stream module to figure it out. (sorry, I have little free time atm, feel free to ask questions thou 🐶)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants