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

Fix: Only emit error events when there is a listener (fixes #35) #36

Merged
merged 1 commit into from
Feb 14, 2018

Conversation

phated
Copy link
Member

@phated phated commented Feb 2, 2018

cc @contra @erikkemperman @th0r @stevelacy @gauntface

Based on the feedback in the other PR (#34), do you all agree that this is actually a bug and should be fixed in the way presented in this PR? I also described it in #35 but will quote that here:

It seems that this is a bug and it isn't likely that someone would rely on the "crashing" behavior (plus, it was never spec'ed by the tests). However, someone might want to attach an error listener and do something with the errors (outside of the gulp task system), so we should keep emitting errors. We can guard against the crash behavior by looking up if there's any handlers for 'error' and only emitting if any exist.


watcher = watch(outGlob, function(cb) {
cb(expectedError);
setTimeout(done, timeout * 3);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just wondering, what is the 3 for, could it be a different number and affect the result?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's just a conservative number - the test below uses timeout * 3 also.

@erikkemperman
Copy link
Member

LGTM!

@gauntface
Copy link

LGTM

@phated phated merged commit ad96e3f into master Feb 14, 2018
@phated phated deleted the emit-only-when-listener branch February 14, 2018 20:16
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

Successfully merging this pull request may close these issues.

4 participants