Bug fix - listener leaks in case of nested wrapped methods and an error in the method#38
Open
yoavaa wants to merge 5 commits intoothiym23:masterfrom
Open
Bug fix - listener leaks in case of nested wrapped methods and an error in the method#38yoavaa wants to merge 5 commits intoothiym23:masterfrom
yoavaa wants to merge 5 commits intoothiym23:masterfrom
Conversation
…ror, it pops the listenerStack only once, casing a leak of listeners into scopes they should not take effect on
Owner
|
Thanks for this patch! Unfortunately, some of your new tests aren't passing: A few things have changed on master since you wrote this (I rebased your patch against current master), so it's possible things need a little adjustment. It's also possible that something's changed in iojs that's affected this. If you can get the tests passing or tweaked to your satisfaction, I'd be happy to merge this. |
…ror, it pops the listenerStack only once, casing a leak of listeners into scopes they should not take effect on
Author
|
I have removed unneeded test - apparently something different has fixed the trigger for this fix - that if you imported domains after async listener you got some strange things happening. removed the obsolete test. |
Author
|
But still, the PR is still valid - it fixes cases of nested callback wrapping |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug is subtle but still there -
If we have two nested methods that are both wrapped by
glue.js, the result is that create will be called twice for the same tick. This by itself is not a big problem. The important thing is that the list of listeners is pushed twice intolistenersStackHowever, if the callback passed to those two have an exception, the
asyncCatchermethod in glue.jsonly pops
listenersStackonce.Once example where this may happen is if we import domains after async-listener, the domain import causes
process.nextTickto call async listener twice. The reason is because domain replaces the underlying_currentTickHandlermethod. If domain is loaded after async listener, the_currentTickHandlermethod is replaced with a wrapped method (wrapped by async listener).The net result is that
if we load async-listener, then domain, we will have both
process.nextTickand_currentTickHandlerwrapped.if we load domain, then async-listener, we will have only
process.nextTickwrapped.I have included two new test files to demonstrate the two cases as well as a fix to the problem. Just run the test cases without the fix and you can see the problem.
See the files
`````` double-calls-to-create-if-importing-domain-after-async-listener.tap.js
double-calls-to-create-not-happening-if-importing-domain-before-async-listener.tap.js```Also note that the problem is not local to just domains. I have noticed that using
fs.readFilecallsfs.opendirectly passing the same callback, resulting in nested wrapped methods and the same issue.