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
Event Listener Leak #104
Comments
Yeah, that sounds like a bug, alright. Thanks for doing such a thorough investigation! |
No problem, thanks for such a quick response! Do you have any suggested patch in the mean time? |
I think the fix would be to store a reference to the If this works, please submit it as a pull request. |
Not |
+1 hopefully the issue gets fixed soon |
+1 |
+1, this is breaking our app. |
I ran into the same problem and implemented the proposed solution of calling removeAllListeners on the client stream, but it didn't work. After doing some debugging, I figured that removeAllListeners doesn't seem to work unless you specify the event to remove (contrary to what the documentation says. But of course, this wouldn't be the first time documentations lies... :-) In any case, I fixed the issue by explicitly removing all the events in the destroy function:
Prior to that, I capture the client stream when the _rpcClient variable is initialized (line 107):
|
Update: I then noticed that calling the destroy function, while preventing the event listener leak, it seems to cause the phantomjs process to stay after spooky is finished. I'm using it with cucumber.js, creating a Spooky instance at the beginning of each scenario, so I end up with multiple phantomjs process hanging around at the end. |
In an web app I am making I continually spawn and destroy spooky instances using the built in ".destory()" method.
This works, but every eleventh spooky respawn I get a double EventEmitter memleak warning (see below for raw dump).
Poking around the spooky and tiny-json-rpc sources pinned this line in tiny-json-rpc as the source of the error:
What I think is happening is that when the spooky object is destroyed it doesn't clear these listeners from its _rpcClient object, thus causing these leaks.
I could be way off base, but I'm pretty sure that's what's going on.
Error:
The text was updated successfully, but these errors were encountered: