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

Chrome have not captured in X ms, killing #1206

Closed
adrianhara opened this issue Oct 9, 2014 · 35 comments
Closed

Chrome have not captured in X ms, killing #1206

adrianhara opened this issue Oct 9, 2014 · 35 comments

Comments

@adrianhara
Copy link

I've started having this issue on our build machine recently (like, a few days ago). The build is run by a bamboo agent which is basically a windows service which launches "grunt". The grunt task then runs karma (among other things) for the tests. When run by the agent the build fails with this message (after 2 tries).

Running the same command line as the agent starts karma, captures the browser and generally works fine. Increasing the timeout to 3 min instead of 1 didn't help.

Did something change recently in karma that might be causing this behavior when it's run by a service without UI?

l.e.: tried with PhantomJS and IE as well, same. So I'm guessing it's a problem with Karma.

@provegard
Copy link

I'm seeing the exact same problem on a TeamCity build server. X = 60000 for me. I too can run the tests just fine on the build server as the TeamCity build agent user.

I have a passing build on October 7 and the first failing on October 9. I have Karma locked to 0.12.23 in package.json so it's unlikely that Karma itself is the problem. Perhaps a dependency?

My money was initially on Chrome 38, but if you say the problem occurs with PhantomJS also then I guess Chrome is off the hook...

@provegard
Copy link

No it's clearly Chrome in my case. I downgraded to 37 and the problem went away.

@adrianhara
Copy link
Author

Hmm strange, since neither Phantom nor IE worked I assumed it's not the browser. But I'm surely willing to try it, however I can't really find a way to get an older version of Chrome. How did you downgrade to 37?

@provegard
Copy link

I uninstalled Chrome 38.

Then, I followed these instructions to disable updates: http://www.wikihow.com/Completely-Disable-Google-Chrome-Update (although I added the template as a computer policy rather than user policy).

Finally, I installed Chrome 37 from here: https://gallery.technet.microsoft.com/Google-Chrome-version-f0619a1f

@adrianhara
Copy link
Author

Thanks a lot! I reverted to 37 (btw, some registry changes were needed as well to prevent the updates in my case, http://stackoverflow.com/questions/18483087/how-can-i-disable-google-chrome-auto-update and http://www.wintips.org/disable-google-chrome-automatic-update/) and it works!

I also tried the beta 40 build and that one doesn't work either. I guess we should report an issue to chrome so it will be eventually fixed.

@maksimr
Copy link
Contributor

maksimr commented Oct 10, 2014

@adrianhara is problem still reproduce on PhantomJS?

Thanks!

@adrianhara
Copy link
Author

For me yes. PhantomJS works fine when karma is run manually, but starting it from the agent fails to connect to PhantomJS. Same with IE. This is why I initially thought it's a Karma issue, as all three browsers exhibited the same behavior.

Maybe it's a combination of changes? We were using karma 0.10.x until recently (it was hardcoded in package.json) and decided to switch to the latest version a few weeks back. It worked fine with Chrome until a few days ago and then it stopped.

We were actually using PhantomJS some time ago, but there were some other problems with it disconnecting after a failing test and never connecting again, so we switched to Chrome and it's been running since. 90% of our tests are testing logic not UI, so we don't actually care about the browser.

@danhaller
Copy link

I've also experienced this issue. We're using karma + grunt + grunt-karma-runner to run tests against firefox and chrome.

The tests run fine on on a dev machine but fail when the grunt command is issued by a team city build to a team city agent (chrome not captured). Logging on to the agent itself and running the command from within the agent's build folder (i.e. running the same code just not remotely) also works fine.

@maksimr
Copy link
Contributor

maksimr commented Oct 13, 2014

@danhaller try running karma without grunt(karma start) on TeamCity.

@danhaller
Copy link

The problem also exists when running karma start. The problem doesn't appear isolated to karma though, I've noticed that my protractor tests are acting similarly too. The chrome process starts up but no commands appear to reach it.

@johnwojtk
Copy link

My situation is identical to @danhaller's. Any additional information would be appreciated. I hope pausing updates to Chrome isn't necessary because it's an involved process for a temporary gain.

@danhaller
Copy link

A workaround for team city: Start the agent from the command line instead of as a windows service. Not ideal, but easier than downgrading chrome.

There's a bug report on the chrome bug tracker here

@johnwojtk
Copy link

Not ideal, but totally works. Karma runs and my builds are successful for the first time in 6 days. Thanks! I'll be keeping an eye on this issue until its resolution.

Here is a link about starting the BuildAgent from the command line for those who are lazy:
https://confluence.jetbrains.com/display/TCD8/Setting+up+and+Running+Additional+Build+Agents#SettingupandRunningAdditionalBuildAgents-StartingtheBuildAgent

@arsuceno
Copy link

Same problem here using CCNet/Karma as Windows Service. It started failing after updating Chrome to 38.0.2125.101 on 2014/10/08. There is no problem when running from command line.

@theodorejb
Copy link

@blackjid
Copy link

I just get an update to 38.0.2125.111 and it works fine

@Mistrall
Copy link

Same problem when we are running from Bamboo build. Will try to downgrade chrome

@tdekoning
Copy link

The issue is resolved in Chrome 41.X (Currently Chrome Canary is on that version).

@johnwojtk
Copy link

Yep, Chrome 39 should include a fix. This is mentioned in the chromium issue linked to by @theodorejb. It's expected to be released on November 20th.

@mradamlacey
Copy link

You can manually update to Chrome 39 by navigating to chrome://chrome in your browser (I tried today and this worked).

My understanding is that 39 will be pushed in automatic updates in the next couple weeks.

@dignifiedquire
Copy link
Member

Closing, as this seems to be resolved, please comment / reopen if you are still experiencing this issue.

@Wasmoo
Copy link

Wasmoo commented Jun 30, 2015

Having trouble with Chrome Version 43.0.2357.130 m. Chrome opens with a page that says "Karma Starting", but Karma can't seem to capture the results.

PhantomJS works fine.

Karma v0.12.37

@dignifiedquire
Copy link
Member

@Wasmoo Please try to open the dev tools and post your console output in general mode and in debug mode please

@hatton
Copy link

hatton commented May 25, 2016

For me, the problem turned out to actually just be that some days, the agent really did take longer than 6 seconds to spin up the browser and connect to Karma. Since the agent shares the hardware, sometimes it would get up in time, sometimes it wouldn't. Changed the timeout to 15 seconds, and all was well.

@krmannix
Copy link

I'm having this issue as well, on a wercker box. Haven't done anything, builds just starting failing beginning of this week. Our timeout is 60s, so that doesn't seem to be an issue

@krmannix
Copy link

I was able to resolve this with this workaround

@chrismwendt
Copy link

My problem was that Karma was attempting to execute a nonexistent file because my CHROME_BIN environment variable pointed to a file that did not exist.

To solve this, make sure Karma browser environment variables (CHROME_BIN, FIREFOX_BIN, etc.) are either unset, or point to existing binaries. For a full list, see this GitHub search: user:karma-runner ENV_CMD. You can check this by running echo $CHROME_BIN.

You can also get the exact shell command that Karma is executing to try it yourself and see if it fails. To do that, modify ./node_modules/karma/lib/launchers/process.js like so:

   }
 
   this._execCommand = function (cmd, args) {
+    log.error([cmd, args.join(' ')].join(' '));
     if (!cmd) {
       log.error('No binary for %s browser on your platform.\n  ' +

Here's the output of env CHROME_BIN=/blah ...:

image

Karma waits, not realizing that the binary doesn't exist.

@Tenmak
Copy link

Tenmak commented Oct 18, 2017

I had the same issue, and it was not cause by either the CHROME_BIN being unset or incorrect, nor the chrome / chromium browser version; and even the --no-sandbox option was not helping.

The issue is that I needed to setup the proxy environment variables for my Jenkins job (run through a docker) to ensure npm could install dependencies, and I simply forgot to reset the environment variables once the dependencies were downloaded.

Local headless chrome needed no proxy configuration in my case, hence :

export HTTP_PROXY= &&\
export HTTPS_PROXY= &&\
ng test --single-run --progress=false

Hope this helps those in trouble


EDIT : It's actually better to simply set a NO_PROXY env variable :
export NO_PROXY="localhost, 0.0.0.0/4201, 0.0.0.0/9876"


N.B : At first I used Chromium, and decided to switch to google-chrome latest versions because of protractor tests. I actually ran into @chrismwendt issue, and his little edit allowed me to find that my karma was using (I don't know how) a chromium bin env variable, even though I did set it correctly with the dockerfile !

The only fix is to re-set this env variable in my jenkins job as well :

# Set CHROME_BIN because it is incorrect even from Dockerfile
export CHROME_BIN=/usr/bin/google-chrome

@luettenberg
Copy link

@Tenmak
Thanks for your hint. That solved our problem too.

@papaiatis
Copy link

Can't believe it was the proxy setting... Thank you @Tenmak !!

@TristanMarion
Copy link

@Tenmak it worked for me, thanks a lot !

@vlodko
Copy link

vlodko commented Jun 15, 2018

this worked for me on the build server:

  1. install puppeteer

  2. add this line to karma conf at the top:
    process.env.CHROME_BIN = require('puppeteer').executablePath();

  3. add this block to karma conf:

    browsers: ['Chrome'],
    browserDisconnectTimeout: 10000,
    browserDisconnectTolerance: 3,
    browserNoActivityTimeout: 60000,
    flags: [
      '--disable-web-security',
      '--disable-gpu',
      '--no-sandbox'
    ]

@arunprasathv
Copy link

arunprasathv commented Jun 27, 2018

I'm facing the same issue on build server, it works fine on local machine. tried multiple settings nothing helps. not sure why it fails on build server. is it a valid proxy settings ? doesnt work with this env variable.
image

My karma config settings,

browsers: ['ChromeNoSandbox'],
browserDisconnectTimeout: 10000,
browserDisconnectTolerance: 3,
browserNoActivityTimeout: 60000,
// reporters: ['progress', 'coverage'],
customLaunchers: {
ChromeNoSandbox: {
base: 'Chrome',
flags: [
'--headless',
'--disable-gpu',
'--disable-translate',
'--disable-extensions',
'--no-sandbox',
'--remote-debugging-port=9222',
]
}
},

@mohyeid
Copy link

mohyeid commented Aug 4, 2018

On my case I am suspecting that when I start chrome outside of karma, it output
DevTools listening on ws://127.0.0.1:9222/devtools/browser/85057d3a-17c3-455a-a50f-124c4f6f62ea

How do I disable the DevTools?

@Yrkki
Copy link

Yrkki commented Jun 14, 2020

@Tenmak

...

Local headless chrome needed no proxy configuration in my case, hence :

export HTTP_PROXY= &&\
export HTTPS_PROXY= &&\
ng test --single-run --progress=false

Hope this helps those in trouble

EDIT : It's actually better to simply set a NO_PROXY env variable :
export NO_PROXY="localhost, 0.0.0.0/4201, 0.0.0.0/9876"

...

Saved my life!!! :)

Thank you lots!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests