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

random DISCONNECTED messages from PhantomJS #598

Closed
ibawt opened this issue Jun 25, 2013 · 47 comments
Closed

random DISCONNECTED messages from PhantomJS #598

ibawt opened this issue Jun 25, 2013 · 47 comments

Comments

@ibawt
Copy link

ibawt commented Jun 25, 2013

Hi,
Karma: 0.8.6
PhantomJS: 1.9
Node: v0.10.2, v0.10.7

I'm seeing random disconnect messages in single run mode. Is this a known problem? I tried monkey patching the socket.io transports to only do xhr and jsonp but it still happens. Any ideas?

@vojtajina
Copy link
Contributor

I believe there was some issue with Node + socket, it should be fixed in Node 0.10.12, can you try to udpate node ?

@glyphobet
Copy link

We are having this too, with these versions:

  • PhantomJS 1.8.2
  • Karma 0.9.4
  • Node 0.10.12

@ibawt
Copy link
Author

ibawt commented Jul 2, 2013

same issue with the latest node.

@vratojr
Copy link

vratojr commented Jul 26, 2013

Same problem with:

Phantom 1.9.1
Karma 0.8.7
Node 0.10.15

@calystoramesh
Copy link

same problem for me,
windows XP

Node: v0.10.21
Karma v0.10.4
Phantom 1.9.2

@apraditya
Copy link

Same here with:

  • Phantom 1.9.2
  • Karma 0.9.3
  • Node 0.10.5 and 0.10.21

@vojtajina
Copy link
Contributor

Can you guys try to debug it a bit to see what's going on in the browser?
https://github.com/ariya/phantomjs/wiki/Troubleshooting

@vojtajina
Copy link
Contributor

It might be related to #558.

@NateRedding
Copy link

I keep having this problem too - everything works fine in Chrome, but switching to PhantomJS seems to result in unpredictable behavior. I have tried configuring each of the different transport options individually, but typically get the same behavior.

OS: Mac OS X - 10.9.2 (Mavericks)
Node: 0.10.26 (installed via homebrew)
PhantomJS: 1.9.7
Karma: 0.12.0

Here is the output (the test that fails varies from run to run):

WARN [PhantomJS 1.9.7 (Mac OS X)]: Disconnected (1 times), because no message in 10000 ms.

PhantomJS 1.9.7 (Mac OS X): Executed 108 of 559 DISCONNECTED (30.895 secs / 21.301 secs)

@NateRedding
Copy link

I have it configured for debugging... is there any particular information that would help? I don't seem to get much info from the Network or Timeline tabs. I can turn on profiling, but I'm not sure how much that will tell us... actually it seems like the disconnect causes Phantom to shutdown before the profiling information is returned. Do you have any suggestions on good places to put breakpoints maybe?

@readme42
Copy link

readme42 commented May 5, 2014

Same Problem here:

PhantomJS 1.9.7 (Linux): Executed 99 of 304 SUCCESS (0 secs / 0.567 secs)
WARN [PhantomJS 1.9.7 (Linux)]: Disconnected (1 times), because no message in 10000 ms.
PhantomJS 1.9.7 (Linux): Executed 99 of 304 DISCONNECTED (13.154 secs / 0.567 secs)

This problem occurs randomly, sometimes everything is fine, sometime it breaks. But when it breaks, it breaks always at test 99.

Karma 0.12.4
PhantomJS 1.9.7
grunt-karma 0.8.0
Node 0.10.26

@bitwiseman
Copy link
Contributor

I'm getting this on other browsers than phantomJS on karma 0.12.16.

@geekytime
Copy link

I'm getting this on other browsers than phantomJS on karma 0.12.16.

I have multiple configurations for multiple browsers that work when I have singleRun: false in my config. As soon as I set singleRun:true, I get this:

DEBUG [karma]: A browser has connected on socket tmAcxXBuoIKtPUKBtY0z
INFO [Firefox 29.0.0 (Mac OS X 10.9)]: Connected on socket tmAcxXBuoIKtPUKBtY0z with id 51306248
DEBUG [launcher]: Firefox (id 51306248) captured in 14.92 secs
WARN [Firefox 29.0.0 (Mac OS X 10.9)]: Disconnected (1 times), because no message in 10000 ms.

DEBUG [karma]: Run complete, exitting.

This is happening in PhantomJS, Chrome, and Firefox.

@sylvain-hamel
Copy link
Contributor

I had a similar problem on my continuous integration server at work. I found out that the machine was so busy that it was in fact timing out for real. I set the timeout to 30 sec and that solved the problem. I'm not saying that this is a final solution for you guys but if you increase the timeout and and it stops failing, we might have more information to investigate.

@geekytime
Copy link

I set the timeout to 30 sec and that solved the problem.

The captureTimeout option defaults to 60 seconds, right? And the browsers are getting captured, fine, so I didn't think that one would help.

I dug around the docs looking for other timeout options, but I couldn't find any. Is there maybe another hidden option for a "wait for execution to start" timeout?

@sylvain-hamel
Copy link
Contributor

There are 4 timeouts, from config.js in source code

  this.captureTimeout = 60000;
  this.browserDisconnectTimeout = 2000;
  this.browserDisconnectTolerance = 0;
  this.browserNoActivityTimeout = 10000;

I dont remember which one I changed but browserNoActivityTimeout could be the one. I don't have access to my work PC right now. Let us know if one of the above helps.

@geekytime
Copy link

browserNoActivityTimeout could be the one

Yup. That did the trick! I should have thought to check the source. Thanks for your help!

@sylvain-hamel
Copy link
Contributor

Sure!

@bajtos
Copy link

bajtos commented Jun 24, 2014

browserNoActivityTimeout could be the one

Works for me too 👍

@readme42
Copy link

For me too 👍

@jhuesos
Copy link

jhuesos commented Jul 4, 2014

It solved the problem for me too.

Can we add this modification to the code? Is there any problem with that? SCRATCH THAT!

I see you can see that option in the karma conf file...

@sabarasaba
Copy link

It solved the problem for me as well.

@kcrwfrd
Copy link

kcrwfrd commented Sep 16, 2014

Once our test suite got to a certain size, our build server started consistently failing to complete the tests. Adjusting the timeout settings helped, but didn't resolve the issue—we were still getting failures maybe 30-50% of the time.

Upgrading the server from a 4 GB single core to 16 GB quad-core has solved the problem, for now.

@headbozo
Copy link

I had the issue with PhantomJS when running on the build server. When tests were running on local computer everything was fine but browser kept disconnecting when running on build server. I dug to the core of the problem. Our application start page had a component which was trying to reach external site and it could do it on local computer but that was forbidden on build server. That caused some significant delay while loading page and in turn that led to no activity timeout. Karma just disconnected client because of that and it took me some time to figure out what was the reason. I think it may be better when browser is pinging karma so it could track browser activity than just timeout. Or may be combination of both approaches would be even better when it times out if it does not receive next ping in certain time interval.

@jhuesos
Copy link

jhuesos commented Oct 30, 2014

We are getting this issue more often in some machine even with:

browserNoActivityTimeout: 60000

I will try to increase it even more, but there is something wrong here. Any suggestions, ideas? Thanks

@garethhunt
Copy link

Ran into this problem on our build servers. The root problem was available RAM. PhantomJS is quite memory hungry and was consuming ~75% of the available 2GB RAM. The 1100 tests would take 1m30s to run and then the build would fail when phantomJS failed to disconnect after 60000ms.

Increasing the build node VM RAM from 2GB to 4GB resulted in the 1100 tests completing in 45s and the browser disconnecting within 5s.

Of course this means we need to profile our code to determine why so much memory is utilized...

@mtscout6
Copy link
Member

I've noticed that using pre-processors can cause this to increase as well. Since karma launches the browser then processes all the files. If your preprocessors take a long time to run then I'll bet you see a direct correlation.

@nuweb
Copy link

nuweb commented Mar 4, 2015

I get the same error.
OSX - 10.9.5
Karma version: 0.12.31
phantomjs version 1.9.8
node --version 0.10.33

->grunt karma
Running "karma:unit" (karma) task
INFO [karma]: Karma v0.12.31 server started at http://localhost:9876/
INFO [launcher]: Starting browser PhantomJS
INFO [PhantomJS 1.9.8 (Mac OS X)]: Connected on socket vo0VCply3aIvM70g5H5C with id 93719535
PhantomJS 1.9.8 (Mac OS X): Executed 1 of 9 SUCCESS (0 secs / 0.001 secs)
PhantomJS 1.9.8 (Mac OS X): Executed 1 of 9 DISCONNECTED (12.386 secs / 0.001 secs)
Warning: Task "karma:unit" failed. Use --force to continue.

Aborted due to warnings.

Here's the repo..
https://github.com/nuweb/angularjs-requirejs-jasmine-karma-protractor-seed

@bajtos
Copy link

bajtos commented Mar 4, 2015

Adding the following lines to my karma config solved the problem for me:

     // If browser does not capture in given timeout [ms], kill it
     captureTimeout: 60000,

+    // to avoid DISCONNECTED messages
+    browserDisconnectTimeout : 10000, // default 2000
+    browserDisconnectTolerance : 1, // default 0
+    browserNoActivityTimeout : 60000, //default 10000

Source: codymikol/karma-webpack#8

@nickawatts
Copy link

I encountered the disconnect problem this week too. After way too much experimentation with different combinations of versions of Node, Karma, Karma launchers and PhantomJS, I realized it had to be something I did, not the tools. I eventually figured out that my problem was a very poorly written (authored by, of course, me) Jasmine spec that uses Angular's ngMock.$httpBackend object to unit test an Angular service.

I was doing something like this:

it('should fail on GET request with invalid username/password', function() {
  $httpBackend.whenGET(/.*/).respond(500);
  ...
  $httpBackend.expectGET("authenticate");
  $httpBackend.flush();
});

I'm still not 100% sure why, but this caused something to hang indefinitely, which caused Karma to never respond, which eventually led to PhantomJS timing out. Using .* as a regex for possible URIs is a horrible idea that I had forgotten I did "temporarily".

The point is, if you see too have a problem like what is described here, it's likely to be something going wrong in your test suite and not a bug in Karma or PhantomJS.

tswast added a commit to GoogleCloudPlatform/web-docs-samples that referenced this issue Oct 10, 2016
Increasing it should help with Travis not being able to run the
integration tests.
karma-runner/karma#598
tswast added a commit to GoogleCloudPlatform/web-docs-samples that referenced this issue Oct 11, 2016
Adds `secrets.tar.enc` which contains an API key, so that CircleCI can run
the integration tests. Secret for the tar is configured in the web UI.

Increases the timeout to help with potential flakiness.
http://stackoverflow.com/a/23492442/101923
karma-runner/karma#598
@odikusar
Copy link

I solved this problem by updating the browser
sudo apt-get install chromium-browser
or
sudo apt-get install google-chrome-stable

LeSuisse added a commit to Enalean/tuleap that referenced this issue Jan 16, 2018
This seems like an usual issue [1][2] which is probably related
to the server load.

While not fixing the root cause, this contribution uses a commonly
employed technique: it doubles how long Karma wait for a message
from the browser before disconnecting from it.

[1] karma-runner/karma#598
[2] codymikol/karma-webpack#8

Change-Id: Id809a3c6d518edda6835b9b97eb3e53e438a8cb8
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

No branches or pull requests