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 EventEmitter bug #323

Merged
merged 1 commit into from Mar 9, 2015

Conversation

@Marsup
Copy link
Member

Marsup commented Mar 5, 2015

@geek I finally managed to reproduce the bug reliably !

So basically the explanation is the domain of the beforeEach captures the event emitter that's created, and if it crashes in the context of the test, the error is not caught by the protect of the test but by the one of beforeEach.

I have an idea how to fix it but that's gonna be weird : we should transfer the list of domain.members from the beforeEach to the new domain of the test.
What do you think ?

@geek

This comment has been minimized.

Copy link
Member

geek commented Mar 5, 2015

Does the other PR (#322) fix this test?

@geek geek added the bug label Mar 5, 2015
@Marsup

This comment has been minimized.

Copy link
Member Author

Marsup commented Mar 5, 2015

Nope not at all, but I think it's still worth merging since we do have a path that doesn't exit the domain, or maybe we should just use domain.run, any reason why it's not the case?

@Marsup

This comment has been minimized.

Copy link
Member Author

Marsup commented Mar 5, 2015

So what do you think of my suggestion ?

@geek

This comment has been minimized.

Copy link
Member

geek commented Mar 5, 2015

@Marsup I wish domains wasn't so broken... I think what you are proposing sounds right, with the way domains cascade... give it a try

@Marsup

This comment has been minimized.

Copy link
Member Author

Marsup commented Mar 5, 2015

Honestly with this use case, I'm not even sure async-listener would help, I don't know it well enough yet.
I'll work in this PR to fix it if you don't mind so don't close it yet.

@Marsup Marsup force-pushed the Marsup:ee-bug branch from f45e3b8 to ce2a9eb Mar 8, 2015
@Marsup Marsup force-pushed the Marsup:ee-bug branch from ce2a9eb to 1ad56f0 Mar 8, 2015
@Marsup

This comment has been minimized.

Copy link
Member Author

Marsup commented Mar 8, 2015

@geek so my solution wasn't possible, since we don't manually register EEs and there's no way to get a list of them, and anyway it would have been functionally wrong.

Here's a patch that should fix domains once and for all, but it's not pretty. I can't say I'm 100% sure we won't see other edge cases considering the complexity of domains.

What happens with this patch is, since we can't know the exact origin of the error (still looking into that), we'll make all the started tests depending on an EE crash.
Let's say you have a beforeEach with an EE, and tests [A, B, C], if an error occurs during B, A and B will get the error, not C, that means that if A passed, it will error as Multiple callbacks or thrown errors received..., which is probably right since A could have caused the error after it passed and then make B crash. This gets ugly really fast if you enable parallel testing, a single EE throwing will make all of your tests depending on it crash.

To compensate, I'm now bringing back the real call stacks, so even if all of your tests crash, you will at least see the origin.

Another issue that will need to be fixed is errors that happen once the test suite is finished, they just go silent, but honestly after this patch I just wanna die so it'll wait :)

@Marsup Marsup changed the title Demonstrate the EventEmitter bug Fix EventEmitter bug Mar 8, 2015
@geek geek self-assigned this Mar 9, 2015
@geek geek added this to the 5.5.0 milestone Mar 9, 2015
@geek

This comment has been minimized.

Copy link
Member

geek commented Mar 9, 2015

@Marsup nicely done, quite the feat!

geek added a commit that referenced this pull request Mar 9, 2015
Fix EventEmitter bug
@geek geek merged commit 146c058 into hapijs:master Mar 9, 2015
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@Marsup Marsup deleted the Marsup:ee-bug branch Dec 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.