-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
clean up after event listeners #282
Comments
+1 for the issue |
@matthewmueller Could you provide a test example? |
in my case, after adding a .wait(selector) action into the test, it runs into this situation. Any idea? or solution? |
The fix/hack is to add To reproduce the warning message, remove I wonder if there is actually a memory leak going on ❓ |
process.setMaxListeners(0); is making no difference here - definitely seems related to the use of wait(). mocha 2.3.3, node 4.1.2, nightmare 2.0.7 |
Same problem here. process.setMaxListeners(0) did not make a difference. |
+1 for the issue |
1 similar comment
+1 for the issue |
It seems to me that using nightmare in a long running/concurrent setup is prone to many errors and can cause all kinds of hiccups. Firstly, there are some things to consider when registering a global (process) event handler in the ctor of any class, but in this specific case it's pretty important to clean them up in all cases that can be considered a shutdown/dtor scenario for nightmare:
This also applies for some of the control flow, which can cause nightmare to hang if the electron process abnormally quits, as it does not reject in those cases (mainly never returning from I have created a preliminary feature branch on my fork of nightmare that tries to tackle these, but it's not cleaned up. Basically it tries to achieve multiple things:
I am not yet convinced this is the best solution, so I am not yet issuing a pull request, but you can take a look here: fr-@c22b45c It does seem to work for largely concurrent runs in my test cases, though. Any input appreciated! |
My research: as @fr stated it's about a long test run but I believe it's related to number of tests rather than physical time (to be specific). In my case commenting one By looking into https://github.com/segmentio/nightmare/blob/master/lib/actions.js I can see there's one common thing between |
@Namek from what I can see there are multiple issues at the same time that also but not exclusively manifest themselves in warnings about about too many registered
The above points are being handled by the feature branch I posted, with the slight caveat that the meaning of shutdown is a matter of definition, but can be classified as in my previous comment. The second part of the issue is handling abnormal exits and failure to start the underlying electron process. In these cases one also needs to ensure that none of the actions that are waiting on
So coming back to In any case, as far as I can see there seem to be no more implications other than the aforementioned leading to the behavior described; but I haven't really had the time to dig any further, which is why I was looking for more input on the branch. Btw: The As a general note: It does seem a bit unsafe to use |
I'm also running into this, when using |
I have a pretty long running nightmare process that runs into this issue. it seemed fine until I got to the last method which involved setting and clicking a lot of form fields. I tried to move the code into just a couple of evaluate blocks to possibly keep the number of events down but that didn't seem to work. has anyone made any progress on this issue? |
One hack to get around the issue is to add
to the ipc.js file in nightmare > lib. Note that this is dangerous and could easily lead to memory leaks. |
+1 for the issue |
Still getting this using the latest version. |
+1 |
1 similar comment
+1 |
This is one of several issues @fr- noted in segment-boneyard#282. It is also important because the registered listener could cause the Nightmare instance to be retained even if there are no other references to it, which means instances can never be garbage collected. This also removes the uncaught exception listener on the parent process, as mentioned in segment-boneyard#586 (comment). Finally, ensure the instance gets marked as ended even if the child process connection has already died (e.g. it crashed).
+1 |
3 similar comments
+1 |
+1 |
+1 |
This was fixed with #407 |
if you're running these things concurrency, it's pretty easy to run into:
The text was updated successfully, but these errors were encountered: