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

protractor hangs indefinitely on "[launcher] Running 1 instances of WebDriver" - when running with xvfb #2419

Open
borisdiakur opened this issue Aug 12, 2015 · 72 comments

Comments

@borisdiakur
Copy link

At first glance this issue seems to be related with #1764 but I don't see how a network issue can cause the hanging here (directConnect is set to true). So here is the setup:

protractor-config.js

'use strict';

/* globals jasmine, browser */
exports.config = {
    allScriptsTimeout: 300000, // 5 min

    // Spec patterns are relative to this directory.
    specs: [
        'protractor/*.js'
    ],

    capabilities: {
        'browserName': 'chrome',
        version: '',
        platform: 'ANY'
    },

    directConnect: true,

    baseUrl: 'http://localhost:3000/', // gets overwritten

    troubleshoot: true,

    framework: 'jasmine',
    onPrepare: function beforeProtractorRuns() {
        browser.driver.manage().window().setSize(1280, 1024);

        // Disable animations so e2e tests run more quickly
        var disableNgAnimate = function () {
            angular.module('disableNgAnimate', []).run([
                '$animate',
                function ($animate) {
                    $animate.enabled(false);
                }
            ]);
        };
        browser.addMockModule('disableNgAnimate', disableNgAnimate);

        // see: https://github.com/angular/protractor/issues/60
        require('jasmine-reporters');
        var capsPromise = browser.getCapabilities();
        capsPromise.then(function setOutputDir(caps) {
            var browserName = caps.caps_.browserName.toUpperCase();
            var browserVersion = caps.caps_.version;
            var filePrefix = browserName + '-' + browserVersion + '-';
            jasmine.getEnv().addReporter(
                new jasmine.JUnitXmlReporter(
                    'build/reports/testresults',
                    true, //consolidate: save nested describes within the same file as their parent
                    true, //useDotNotation: separate suite names with dots rather than spaces (ie "Class.init" not "Class init")
                    filePrefix
                )
            );
        });
    },

    jasmineNodeOpts: {
        isVerbose: true,
        showColors: true,
        includeStackTrace: true,
        defaultTimeoutInterval: 300000, // 5 min
    }
};

Here is an extract of the essential parts of the Jenkins Job console log:

⋮
13:28:22 DEBUG - Running with --troubleshoot
13:28:22 DEBUG - Protractor version: 2.1.0
13:28:22 DEBUG - Your base url for tests is http://localhost:57505/
13:28:22 Using ChromeDriver directly...
13:28:22 [launcher] Running 1 instances of WebDriver
13:28:22 DEBUG - WebDriver session successfully started with capabilities { caps_: 
13:28:22    { acceptSslCerts: true,
13:28:22      applicationCacheEnabled: false,
13:28:22      browserConnectionEnabled: false,
13:28:22      browserName: 'chrome',
13:28:22      chrome: { userDataDir: '/tmp/.com.google.Chrome.AuA2qr' },
13:28:22      cssSelectorsEnabled: true,
13:28:22      databaseEnabled: false,
13:28:22      handlesAlerts: true,
13:28:22      javascriptEnabled: true,
13:28:22      locationContextEnabled: true,
13:28:22      mobileEmulationEnabled: false,
13:28:22      nativeEvents: true,
13:28:22      platform: 'Linux',
13:28:22      rotatable: false,
13:28:22      takesHeapSnapshot: true,
13:28:22      takesScreenshot: true,
13:28:22      version: '44.0.2403.125',
13:28:22      webStorageEnabled: true } }
13:28:30 Testing foobar
13:28:30   Setup
13:28:30     should display foobar - pass
⋮                                                   <--- more describe-s and it-s
13:28:35 Finished in 12.616 seconds
13:28:35 2 tests, 9 assertions, 0 failures
13:28:35 
13:28:35 [launcher] 0 instance(s) of WebDriver still running
13:28:35 [launcher] chrome #1 passed
⋮                                                   <--- other tests scenarios also run successfully
13:28:47 DEBUG - Running with --troubleshoot
13:28:47 DEBUG - Protractor version: 2.1.0
13:28:47 DEBUG - Your base url for tests is http://localhost:34976/
13:28:47 Using ChromeDriver directly...
13:28:47 [launcher] Running 1 instances of WebDriver <--- hanging from here,
                                                          can't figure out why,
                                                          wish I had logs : [
15:05:23 Xvfb stopping                               <--- canceled build manually,
                                                          see time difference, no timeouts triggered,
                                                          neither from Protractor nor from WebDriver : [
15:05:23 Build has been canceled

Note that it is not always the same tests scenario which leads to the hanging.
Same problems with node 0.10.33 as with 0.12.7.
Using Ubuntu 12.04.5 LTS (GNU/Linux 3.13.0-37-generic x86_64).

$ file /opt/google/chrome/chrome
/opt/google/chrome/chrome: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[sha1]=0xe4fc0257b42110fc269782274f1e774718135349, stripped
@dseravalli
Copy link

I opened that other issue. In my case, I was running protractor inside of Vagrant and had port 4444 forwarded in my Vagrantfile. protractor silently failed/hung in this scenario

@caninemwenja
Copy link

I had the same issue but it got fixed when I ran webdriver-manager start in the foreground ie

webdriver-manager start &
protractor conf.js #hangs

but

webdriver-manager start
protractor conf.js #works

@caninemwenja
Copy link

Oddly both styles seem to work now. I'm not sure but I think the nature of the tests may also determine whether protractor hangs or not. I had a test that was infinitely trying to reach a nonexistent location because I hadn't set the baseUrl. Protractor showed the same symptoms.

@PaddyMann
Copy link

I'm getting hanging behaviour, running tests with sharding on Codeship CI.

I run the same tests with Firefox and Chrome - I've split these into 2 separate config files but other than the browser setting they're the same.

The process sometimes hangs at the end of the Chrome file, and sometimes at the end of the Firefox one (and, if I'm very lucky, sometimes doesn't hang :))

Consistently seems to be "1 instances" left running (rather than 2 or more).

It's run as a foreground process so no help from @caninemwenja 's comment...

@Callmenorm
Copy link

I've got a similar issue, where it hangs at

Using ChromeDirver directly...
[launcher] Running 1 instances of WebDriver

about 50% of the time. It will hang there indefinitely. However, even if it hangs you can start other instances which may or may not succeed in the same manner.

@PaddyMann
Copy link

I've experienced the issue both with and without directConnect so that's not part of the issue

@Callmenorm
Copy link

Yeah, I've just confirmed that the same things happens with directConnect and standalone selenium.

@jrust
Copy link

jrust commented Aug 19, 2015

Also seeing the problem, but only on our Ubuntu build servers. Haven't seen the issue yet on the Windows servers. Using Google Chrome 44.0.2403.130 and ChromeDriver 2.15.322448.

@Callmenorm
Copy link

I don't know how significant it is, but its also our Ubuntu build servers which are affected. We have fedora, ubuntu, and OSX systems, but its only the Ubuntu servers which hang at the ChromeDriver start up.

@caninemwenja
Copy link

Ubuntu for me too. Using Chromium 43.0.2357.130 and ChromeDriver 2.16. It works now though (with no apparent change).

@PaddyMann
Copy link

We're on Ubuntu too (- using Codeship and their servers are based on Ubuntu Trusty)

@borisdiakur
Copy link
Author

We're on Ubuntu as well (updated issue description with system information "Ubuntu 12.04.5 LTS (GNU/Linux 3.13.0-37-generic x86_64)").

@Callmenorm
Copy link

The ubuntu servers also use Xvfb (X Virtual Frame Buffer) to use the browser without a window manager.

@NickTomlin
Copy link
Contributor

Interesting; i've experienced some weird hang ups on Debian (wheezy) when using Xvfb. They seemed to be due to the browser not being able to attach to the headless display. Is everyone here attempting to run things via Xvfb?

@tullmann
Copy link
Contributor

If you're having problems racing with Xvfb startup try using xdpyinfo to wait for X to be ready:

MAX=120 # About 60 seconds
CT=0
while ! xdpyinfo >/dev/null 2>&1; do
    sleep 0.50s
    CT=$(( CT + 1 ))
    if [ "$CT" -ge "$MAX" ]; then
        LOG "FATAL: $0: Gave up waiting for X server $DISPLAY"
        exit 11
    fi
done

LOG "X is available"

Also, you can get more logs from chromedriver itself. Those often have more details about what went wrong (but often don't have enough useful info, either). Often we have to look into the chrome debug logs, too. See http://stackoverflow.com/questions/31662828/how-to-access-chromedriver-logs-for-protractor-test for suggestions on how to get additional chromedriver logs.

@jrust
Copy link

jrust commented Aug 20, 2015

Yup, using xvfb-run on ubuntu and (obviously) not using it on the windows build servers so that sounds like a definite possibility. @tullmann do you use your script in conjunction with xvfb-run or Xvfb?

@Callmenorm
Copy link

We have put xvfb in our init scripts, so as far as I know it is running soon after startup. Unless there is something else that needs to be done to make sure that it's "Ready" to accept connections, then I think xvfb is "ready" in my case.

@borisdiakur
Copy link
Author

@tullmann We also have xvfb running from the beginning and some of the tests run fine before the hanging. But thanks for the chromedriver logs hint. Will try that as soon as possible.

@ArwinLin
Copy link

I'm using windows server 2012. If I run webdriver-manager start in the foreground there is no problem. But if I run it in the background, similar "hanging behavior" will happen- about 1.5 minute for each browser.
I also try standalone selenium server so that I can skip the step webdriver-manager start. The test runs without problem if I start it locally. But if I remotely use psexec on other machine to run the test, it will run in background and the hanging behavior will happen again.

@borisdiakur
Copy link
Author

I managed to enable chrome driver logs (using this method).
Here is the result:

[0,014][INFO]: COMMAND InitSession {
   "desiredCapabilities": {
      "browserName": "chrome",
      "count": 1,
      "platform": "ANY",
      "version": ""
   }
}
[0,014][INFO]: Populating Preferences file: {
   "alternate_error_pages": {
      "enabled": false
   },
   "autofill": {
      "enabled": false
   },
   "browser": {
      "check_default_browser": false
   },
   "distribution": {
      "import_bookmarks": false,
      "import_history": false,
      "import_search_engine": false,
      "make_chrome_default_for_user": false,
      "show_welcome_page": false,
      "skip_first_run_ui": true
   },
   "dns_prefetching": {
      "enabled": false
   },
   "profile": {
      "content_settings": {
         "pattern_pairs": {
            "https://*,*": {
               "media-stream": {
                  "audio": "Default",
                  "video": "Default"
               }
            }
         }
      },
      "default_content_settings": {
         "geolocation": 1,
         "mouselock": 1,
         "notifications": 1,
         "popups": 1,
         "ppapi-broker": 1
      },
      "password_manager_enabled": false
   },
   "safebrowsing": {
      "enabled": false
   },
   "search": {
      "suggest_enabled": false
   },
   "translate": {
      "enabled": false
   }
}
[0,014][INFO]: Populating Local State file: {
   "background_mode": {
      "enabled": false
   },
   "ssl": {
      "rev_checking": {
         "enabled": false
      }
   }
}
[0,015][INFO]: Launching chrome: /opt/google/chrome/google-chrome --disable-background-networking --disable-client-side-phishing-detection --disable-component-update --disable-default-apps --disable-hang-monitor --disable-prompt-on-repost --disable-sync --disable-web-resources --enable-logging --ignore-certificate-errors --load-extension=/tmp/.com.google.Chrome.NqAJ9w/internal --log-level=0 --metrics-recording-only --no-first-run --password-store=basic --remote-debugging-port=12199 --safebrowsing-disable-auto-update --safebrowsing-disable-download-protection --test-type=webdriver --use-mock-keychain --user-data-dir=/tmp/.com.google.Chrome.LqJPTu data:,
[0,016][DEBUG]: DevTools request: http://127.0.0.1:12199/json/version
[0,077][DEBUG]: DevTools request failed
[1:1:0909/154445:ERROR:image_metadata_extractor.cc(111)] Couldn't load libexif.
Xlib:  extension "RANDR" missing on display ":2".
[0,127][DEBUG]: DevTools request: http://127.0.0.1:12199/json/version
[0,128][DEBUG]: DevTools request failed
[0,178][DEBUG]: DevTools request: http://127.0.0.1:12199/json/version
[0,179][DEBUG]: DevTools request failed
Xlib:  extension "RANDR" missing on display ":2".
[0,229][DEBUG]: DevTools request: http://127.0.0.1:12199/json/version
[0,230][DEBUG]: DevTools request failed
[58787:58787:0909/154445:ERROR:sandbox_linux.cc(345)] InitializeSandbox() called with multiple threads in process gpu-process
[0,280][DEBUG]: DevTools request: http://127.0.0.1:12199/json/version

In my logs folder I count the occurences in all log files:

$ grep -nr "ERROR:sandbox_linux.cc(345)] InitializeSandbox() called with multiple threads in process gpu-process" . | wc -l
161
$ grep -nr "ERROR:image_metadata_extractor.cc(111)] Couldn't load libexif." . | wc -l
161

@tullmann
Copy link
Contributor

tullmann commented Sep 9, 2015

You can hide/avoid the "multiple threads in process gpu-process" by adding --disable-gpu to the chrome command line. Generally when running under XVFB, you're not leveraging a GPU anyway, so disabling it shouldn't be bad. Anyway, I believe this (and the RANDR and the libexif messages) are harmless messages and just distracting.

Its odd that chromedriver isn't timing out (it looks like you're waiting an hour or more?). You might get more useful information from the chrome logs about what's going on. (The "DevTools request" stuff is from chromedriver trying to establish a basic connection to chrome -- it just polls repeatedly until it gets a connection). It looks like chromedriver receives no reply, but doesn't timeout either ... might be worth comparing this log to a "normal" case to see what the differences are in your setup.)

To get more chrome debug logging add the following arguments to chrome's arguments (in your protractor config): enable-logging, v=1 and userDataDir=<somedir> where <somedir> is a new directory private to this run. (You can leave off userDataDir and chrome will pick a random directory in /tmp, but it can be annoying to figure out which one...)

@borisdiakur
Copy link
Author

Seems like enabling chrome logs fixes a race condition. The build job with chrome logging enabled refuses to hang while the build job without logging still hangs on a regular basis.

@jrust
Copy link

jrust commented Sep 29, 2015

Also enabled logging and still had it hang, but the log has perhaps something useful at the end:

(google-chrome:13094): GConf-WARNING **: Client failed to connect to the D-BUS daemon:
//bin/dbus-launch terminated abnormally without any error message
[13132:13132:0929/003546:ERROR:sandbox_linux.cc(345)] InitializeSandbox() called with multiple threads in process gpu-process

The gpu-process issue has been discussed earlier, but could the d-bus message be related?

@juliemr juliemr changed the title protractor hangs indefinitely on "[launcher] Running 1 instances of WebDriver" protractor hangs indefinitely on "[launcher] Running 1 instances of WebDriver" - when running with xvfb Sep 30, 2015
@juliemr
Copy link
Member

juliemr commented Sep 30, 2015

I'm hoping that this is fixed with the new version of chromedriver in Protractor 2.3.0 and higher. Can anyone confirm?

@jrust
Copy link

jrust commented Oct 7, 2015

@juliemr we've had it running for a few days now and a few hundred builds on 2.4 and haven't seen it hang, so yes, that seems to have fixed it.

@juliemr
Copy link
Member

juliemr commented Oct 7, 2015

Whee! Closing - please open up a new issue if this crops up again.

filipesilva added a commit to angular/angular-cli that referenced this issue Jun 20, 2016
This should help with flakyness on chrome tests, especially e2e.

For more information see:
- angular/protractor#2419 (comment)
- angular/protractor#2419 (comment)
emma-mens pushed a commit to emma-mens/angular-cli that referenced this issue Jul 1, 2016
This should help with flakyness on chrome tests, especially e2e.

For more information see:
- angular/protractor#2419 (comment)
- angular/protractor#2419 (comment)
emma-mens pushed a commit to emma-mens/angular-cli that referenced this issue Jul 1, 2016
This should help with flakyness on chrome tests, especially e2e.

For more information see:
- angular/protractor#2419 (comment)
- angular/protractor#2419 (comment)
@juliemr
Copy link
Member

juliemr commented Jul 14, 2016

@cnishina the problem for Protractor here is that we should time out, instead of hanging, with a reasonable error, if chrome can't start up. Can you take this one?

@cnishina
Copy link
Member

cnishina commented Aug 1, 2016

Hi everyone! I plan to look into the hanging error and improve error reporting.

On a side note, I just created a Jenkins server this weekend to try out a few Protractor tests. It appears there are Xvfb issues. If you are using Jenkins, there is an Xvfb plugin. This is my setup:

  • NodeJS Plugin and have Jenkins install NodeJS 6.3.1 automatically.
  • Xvfb plugin
    • install Xvfb on the machine running the job and set the Xvfb Plugin executable directory to /usr/bin/
    • in the job, enable to option to "start Xvfb before the build, and shut it down after."
  • Job build step:
    • webdriver-manager update
    • npm install
    • npm test

Console output snippets:

Xvfb starting$
+ npm install
npm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue

npm WARN protractor-cookbook-tests@1.0.0 No repository field.
+ npm test

> protractor-cookbook-tests@1.0.0 test /var/lib/jenkins/workspace/protractor-cookbook-jasmine-junit-reports/tests
> jasmine

Started

> junit-reports@1.0.0 pretest /var/lib/jenkins/workspace/protractor-cookbook-jasmine-junit-reports/jasmine-junit-reports
> webdriver-manager update

[11:06:07] I/downloader - selenium standalone: downloading version 2.53.1
[11:06:07] I/downloader - curl -o /var/lib/jenkins/workspace/protractor-cookbook-jasmine-junit-reports/jasmine-junit-reports/node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-2.53.1.jar https://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.1.jar
[11:06:07] I/downloader - chromedriver: downloading version 2.22
[11:06:07] I/downloader - curl -o /var/lib/jenkins/workspace/protractor-cookbook-jasmine-junit-reports/jasmine-junit-reports/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.22linux64.zip https://chromedriver.storage.googleapis.com/2.22/chromedriver_linux64.zip
[11:06:07] I/update - chromedriver: unzipping /var/lib/jenkins/workspace/protractor-cookbook-jasmine-junit-reports/jasmine-junit-reports/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.22linux64.zip
[11:06:07] I/update - chromedriver: setting permissions to 0755 for /var/lib/jenkins/workspace/protractor-cookbook-jasmine-junit-reports/jasmine-junit-reports/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.22

> junit-reports@1.0.0 test /var/lib/jenkins/workspace/protractor-cookbook-jasmine-junit-reports/jasmine-junit-reports
> protractor conf.js

[11:06:09] I/direct - Using ChromeDriver directly...
[11:06:09] I/launcher - Running 1 instances of WebDriver
Started
.F.F

4 specs, 2 failures
Finished in 5.971 seconds
[11:06:15] I/launcher - 0 instance(s) of WebDriver still running
[11:06:15] I/launcher - chrome #01 failed 2 test(s)
[11:06:15] I/launcher - overall: 2 failed spec(s)
[11:06:15] E/launcher - Process exited with error code 1

Xvfb stopping

@cmurczek
Copy link

I'm facing the same issue on Windows. When I try to debug my tests from VSCode Protractor hangs forever at

I/launcher - Running 4 instances of WebDriver

My VSCode launch config runs a powershell script starting the SUT and selenium server in separate processes (using the Start-Process cmdlet). Only after both respond with HTTP 200 the launch config invokes protractor. VSCode debug setup is similar to that of Webstorm as described in the protractor docs. VSCode eventually invokes protractor like follows:

node --debug-brk=<randomPort> node_mdoules\protractor\bin\protractor src\test\protractorConf.js

I also tried using node_modules\protractor\built\cli.js but got the same result. Experimenting with protractor's --debug, debug and --debuggingServer command line options also got me nowhere.

Simply executing the tests from gulp (using gulp-angular-protractor) works fine though.

The only difference I can see between the two (apart from debugger config) is that when running via gulp selenium, browsersync and protractor share standardInput/Output, while in debug mode they are separate. But that wouldn't make a difference, would it?

@danielsuter
Copy link

I'm facing a similar problem on Windows 7 without xvfb. Tests will run but the process never terminate:
tsc && concurrently "http-server -s" "protractor protractor.config.js"

[1] [14:24:54] I/local - Starting selenium standalone server...
[1] [14:24:54] I/launcher - Running 1 instances of WebDriver
[1] [14:24:55] I/local - Selenium standalone server started at http://10.153.242.35:57125/wd/hub
[1] AppDir: ./
[1] Suite: QuickStart E2E Tests
[1] passed - should display: My First Angular 2 App
[1] Suite passed: QuickStart E2E Tests
[1] [14:25:01] I/local - Shutting down selenium standalone server.
[1] [14:25:01] I/launcher - 0 instance(s) of WebDriver still running
[1] [14:25:01] I/launcher - phantomjs #1 passed
[1] protractor protractor.config.js exited with code 0

If I use the following command (copied from the angular quickstart):
tsc && concurrently "http-server -s" "protractor protractor.config.js" --kill-others --success first

[1] AppDir: ./
[1] Suite: QuickStart E2E Tests
[1] passed - should display: My First Angular 2 App
[1] Suite passed: QuickStart E2E Tests
[1] [14:30:48] I/local - Shutting down selenium standalone server.
[1] [14:30:48] I/launcher - 0 instance(s) of WebDriver still running
[1] [14:30:48] I/launcher - phantomjs #1 passed
[1] protractor protractor.config.js exited with code 0
--> Sending SIGTERM to other processes..

It will hang at the last command.

@valburyakov
Copy link

valburyakov commented Oct 21, 2016

I got the same issue on running protractor tests in gitlab CI via docker executor. At the beginning tests run fast and everything is good but after some period of time (30-40 min) tests become extremely slow and protractor hangs out.
First it fails with Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL and then WebDriverError: no such sessionbecause of page crush.
I use official docker container openjdk:7 and install node, chrome, xvfb and set DBUS_SESSION_BUS_ADDRESS =/dev/null. Our application ( on play framework) is also run in this container. Docker runs with privileged mode and volumes /dev/shm:/dev/shm

Xvfb :21 -screen 0 1920x1280x24 &
export DISPLAY=:21.0
grunt test

Protractor 4.0.9, chrome 53, chromederiver 2.24
logs: chromedriver.txt

@zuzusik
Copy link

zuzusik commented Feb 2, 2017

We also had this issue and I can confirm that doing export DBUS_SESSION_BUS_ADDRESS=/dev/null helps 👍

Protractor 5.0.0
Chromedriver 2.26
Ubuntu 16.04
Docker 1.13.0

@attila123
Copy link

attila123 commented Apr 3, 2017

We have the protractor hanging after

14:50:50 [14:50:48] I/launcher - Running 1 instances of WebDriver
14:50:50 [14:50:48] I/hosted - Using the selenium server at http://localhost:7840/wd/hub

even when using the DBUS_SESSION_BUS_ADDRESS workaround. It happens about 20-30% of the cases in our Jenkins builds (even on the very same Jenkins slave).

node.js 6.9.5
protractor 5.1.1
chromedriver 2.28
selenium 3.1.1
webdriver-manager 12.0.2
chrome 56.0.2924.87
(we have fixed these versions from constantly changing and potentially breaking things)
Jenkins slaves are running on CentOS 7
The build does not use docker (yet).

protractor is started by a npm script (in package.json):
"ci-e2e": "bash -c \"set -o pipefail ; export DBUS_SESSION_BUS_ADDRESS=/dev/null ; protractor protractor-conf.js --seleniumAddress http://localhost:${npm_package_config_seleniumPort}/wd/hub 2>&1 | tee .ci/protractor.log\"",
(of course there are pre and post scripts as well to start/stop things)

chromedriver logs are enabled by the following shell script line (run by the pre npm script):
nohup webdriver-manager start --versions.standalone $SELENIUM_STANDALONE_EXPECTED_VERSION --versions.chrome $SELENIUM_CHROMEDRIVER_EXPECTED_VERSION --chrome_logs ${THIS_SCRIPT_DIR}/../.ci/chromedriver.log --seleniumPort $SELENIUM_PORT >.ci/webdriver-manager_start.log 2>&1 &
(there is a 5 seconds sleep after that)

Xvfb is started before webdriver in a similar style (nohup + background)

I just checked the chromedriver log and it shows:

[0.096][INFO]: COMMAND InitSession {
   "alwaysMatch": {
      "count": 1,
      "platform": "ANY",
      "version": "ANY"
   },
   "capabilities": {
      "desiredCapabilities": {
         "browserName": "chrome",
         "chromeOptions": {
            "args": [ "--no-sandbox", "--test-type=browser" ],
            "prefs": {
               "download": {
                  "default_directory": "/tmp/",
                  "prompt_for_download": false
               }
            }
         },
         "count": 1,
         "platform": "ANY",
         "version": "ANY"
      },
      "requiredCapabilities": {

      }
   },
   "desiredCapabilities": {
      "browserName": "chrome",
      "chromeOptions": {
         "args": [ "--no-sandbox", "--test-type=browser" ],
         "prefs": {
            "download": {
               "default_directory": "/tmp/",
               "prompt_for_download": false
            }
         }
      },
      "count": 1,
      "platform": "ANY",
      "version": "ANY"
   },
   "firstMatch": [ {
      "browserName": "chrome",
      "chromeOptions": {
         "args": [ "--no-sandbox", "--test-type=browser" ],
         "prefs": {
            "download": {
               "default_directory": "/tmp/",
               "prompt_for_download": false
            }
         }
      }
   } ],
   "requiredCapabilities": {

   }
}
[0.099][INFO]: Populating Preferences file: {
   "alternate_error_pages": {
      "enabled": false
   },
   "autofill": {
      "enabled": false
   },
   "browser": {
      "check_default_browser": false
   },
   "distribution": {
      "import_bookmarks": false,
      "import_history": false,
      "import_search_engine": false,
      "make_chrome_default_for_user": false,
      "show_welcome_page": false,
      "skip_first_run_ui": true
   },
   "dns_prefetching": {
      "enabled": false
   },
   "download": {
      "default_directory": "/tmp/",
      "prompt_for_download": false
   },
   "profile": {
      "content_settings": {
         "pattern_pairs": {
            "https://*,*": {
               "media-stream": {
                  "audio": "Default",
                  "video": "Default"
               }
            }
         }
      },
      "default_content_setting_values": {
         "geolocation": 1
      },
      "default_content_settings": {
         "geolocation": 1,
         "mouselock": 1,
         "notifications": 1,
         "popups": 1,
         "ppapi-broker": 1
      },
      "password_manager_enabled": false
   },
   "safebrowsing": {
      "enabled": false
   },
   "search": {
      "suggest_enabled": false
   },
   "translate": {
      "enabled": false
   }
}
[0.100][INFO]: Populating Local State file: {
   "background_mode": {
      "enabled": false
   },
   "ssl": {
      "rev_checking": {
         "enabled": false
      }
   }
}
[0.107][INFO]: Launching chrome: /opt/google/chrome/google-chrome --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --disable-web-resources --enable-automation --enable-logging --ignore-certificate-errors --load-extension=/tmp/.org.chromium.Chromium.ekVmsH/internal --log-level=0 --metrics-recording-only --no-first-run --no-sandbox --password-store=basic --remote-debugging-port=12521 --safebrowsing-disable-auto-update --test-type=browser --use-mock-keychain --user-data-dir=/tmp/.org.chromium.Chromium.6KPDEf data:,

Does anyone know how to track this down or how can I provide more debugging information (when it happens)?
Is there some more specific bug report for this somewhere?
Could updating any of the above SW components (e.g. chrome, chrome driver) help?

@attila123
Copy link

I updated chromedriver to 2.29 and chrome to 57. It still happened.
I realized that --enable-logging is passed to chrome (https://www.chromium.org/for-testers/enable-logging) therefore I checked chrome_debug.log in its user data dir (also passed to chrome).

[7072:7072:0406/121917.369242:WARNING:audio_manager.cc(321)] Multiple instances of AudioManager detected
[7072:7072:0406/121917.369280:WARNING:audio_manager.cc(278)] Multiple instances of AudioManager detected
[7146:7146:0406/121917.570450:ERROR:gl_surface_glx.cc(406)] glxQueryVersion failed
[7146:7146:0406/121917.570506:ERROR:gl_initializer_x11.cc(136)] GLSurfaceGLX::InitializeOneOff failed.
[7146:7146:0406/121917.572327:ERROR:child_thread_impl.cc(762)] Request for unknown Channel-associated interface: ui::mojom::GpuMain
[7146:7146:0406/121917.572698:ERROR:gpu_child_thread.cc(330)] Exiting GPU process due to errors during initialization

However on successful runs this also happens and the log continues:

[32566:32598:0406/144120.367781:ERROR:browser_gpu_channel_host_factory.cc(113)] Failed to launch GPU process.
[32566:32598:0406/144120.367832:ERROR:browser_gpu_channel_host_factory.cc(113)] Failed to launch GPU process.
[32566:32598:0406/144120.367863:ERROR:browser_gpu_channel_host_factory.cc(113)] Failed to launch GPU process.
[32566:32598:0406/144120.367888:ERROR:browser_gpu_channel_host_factory.cc(113)] Failed to launch GPU process.
[32566:32598:0406/144120.367912:ERROR:browser_gpu_channel_host_factory.cc(113)] Failed to launch GPU process.
(then the logs from the tests follow)

It seems that https://bugs.chromium.org/p/chromedriver/issues/detail?id=1298 is the related bug report, which was closed without any real solution.

@jean-francois-labbe
Copy link

I have this random issue too.

npm logs:

> NODE_ENV=e2e node_modules/.bin/protractor protractor.others.conf.js

[10:28:22] I/hosted - Using the selenium server at http://selenium-52640-others:4444/wd/hub
[10:28:22] I/launcher - Running 1 instances of WebDriver
ERROR: Job failed: execution took longer than 20m0s seconds

Selenimu logs:

31/05/2017 10:28:0810:28:08.341 INFO - Selenium Server is up and running
31/05/2017 10:28:2210:28:22.780 INFO - SessionCleaner initialized with insideBrowserTimeout 0 and clientGoneTimeout 1800000 polling every 180000
31/05/2017 10:28:2210:28:22.815 INFO - Executing: [new session: Capabilities [{count=1, browserName=chrome, chromeOptions={prefs={download={directory_upgrade=true, default_directory=/tmp/, prompt_for_download=false}}}, version=ANY, platform=ANY}]])
31/05/2017 10:28:2210:28:22.836 INFO - Creating a new session for Capabilities [{count=1, browserName=chrome, chromeOptions={prefs={download={directory_upgrade=true, default_directory=/tmp/, prompt_for_download=false}}}, version=ANY, platform=ANY}]
31/05/2017 10:28:23Starting ChromeDriver 2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320) on port 4676
31/05/2017 10:28:23Only local connections are allowed.

Then nothing until timeout.

@zuzusik
Copy link

zuzusik commented May 31, 2017

Great news for everyone in the thread: from version 59 Chrome will be supporting headless mode, so xvfb will not be needed anymore. Details are here: https://developers.google.com/web/updates/2017/04/headless-chrome

@marcusvetter
Copy link

Hm, the issue with headless chrome (v. 59) is, that sendkey interactions are not supported (you can not enter data into an input field 👎 )

See https://bugs.chromium.org/p/chromedriver/issues/detail?id=1772

@kkrishan
Copy link

kkrishan commented Aug 9, 2018

I am getting similar issue where 1 instance of webdriver remains forever until I abort the test run in jenkins. Protractor hangs at
I/launcher - 1 instance(s) of WebDriver still running

Setup (protractor | headless chrome | docker | jenkins)
protractor 5.3.2
chromedriverVersion: '2.40.565383'
chrome 'version' => '68.0.3440.75'
platform=Linux 3.10.0-862.3.2.el7.x86_64 x86_64)

Docker image :
FROM node:9-stretch
RUN apt-get update &&
DEBIAN_FRONTEND="noninteractive"
apt-get install -y --no-install-recommends
chromium
dbus-x11
dumb-init
libgconf-2-4
openjdk-8-jre-headless
&& rm -rf /var/lib/apt/lists/*
USER node
ENV CHROME_BIN /usr/bin/chromium
ENV DBUS_SESSION_BUS_ADDRESS /dev/null

protractor.conf.js
directConnect: true,
capabilities: {
shardTestFiles: true,
maxInstances: 6,

    'browserName': 'chrome',
    'chromeOptions': {
        args: ['no-sandbox','headless','disable-gpu','window-size=1366,768','enable-logging' ,'v=1','disable-dev-shm-usage'],
    }
},

Tried using : ENV DBUS_SESSION_BUS_ADDRESS /dev/null as suggested in docker file but error still exist.

@lukaslewandowski-pearson

Any progress with this issue? I am using protractor 5.4.0 with "protractor-cucumber-framework": "6.0.0", and if some test fails in parallel mode, instance of webdriver is not shut down and hangs indefinitely.

@rafalf
Copy link

rafalf commented Sep 26, 2018

seeing this as well
Version 5.4.0
Google Chrome 69.0.3497.100

        '--disable-infobars',
        '--disable-notifications',
        '--window-size=1440,900',
        '--headless',
        '--no-sandbox',
        '--disable-gpu',
        '--enable-logging',
        'v=1'

@TheMikeSanto
Copy link

Also seeing this. At first it would only happen intermittently and could be fixed with a restart, now it seems to happen every time.
Protractor 5.4.1
Chrome 69.0.3497.100

/** Protractor configuration */
exports.config = {
  ...
  capabilities: {
    browserName: 'chrome',
    loggingPrefs: {
      browser: 'SEVERE',
    },
    chromeOptions: {
      args: [
        '--allow-running-insecure-content',
        '--use-fake-device-for-media-stream',
        '--use-fake-ui-for-media-stream',
        '--window-size=1920,1080',
        '--enable-gpu-rasterization',
        '--enable-impl-side-painting',
        '--no-first-run',
        '--no-sandbox',
        '--incognito',
        '--headless',
        '--disable-infobars',
        '--disable-session-crashed-bubble',
        '--noerrdialogs',
        '--disable-touch-adjustment',
        '--disable-touch-events',
        '--disable-pinch',
        '--overscroll-history-navigation=0',
        '--disable-setuid-sandbox',
        '--js-flags="--expose-gc"',
      ]
    }
  },
  directConnect: true,
  framework: 'jasmine',
  getPageTimeout: 5000,
  allScriptsTimeout: 5000,
  ...
};

@rafalf
Copy link

rafalf commented Oct 24, 2018

(#4966)

@Izhaki
Copy link

Izhaki commented Oct 24, 2018

Same issue when running parallel tests. Commenting onComplete solved it for us.

@anudeepsinghpatelgithub
Copy link

anudeepsinghpatelgithub commented Nov 12, 2018

I am still facing same error.
I am not using onComplete

below is my config:
`
exports.config = {
framework: 'jasmine2',
getPageTimeout: pageLoadTimeout,
allScriptsTimeout: allScriptsTimeout,
customerCode:customerCode,
useAllAngular2AppRoots: true,
testData:webpackHelper.getTestData(),
//directConnect: true, // this runs selenium server on the fly and it has faster execution + parallel execution efficiently
//and tests are more stable with local server started instead of directConnection.
baseUrl: 'http://localhost:3000',
capabilities: {
browserName: 'chrome',
shardTestFiles: true,
maxInstances: 5,
chromeOptions: {
args: [
'disable-extensions',
'disable-web-security',
'--start-fullscreen', // enable for Mac OS
'--headless', // start on background
'--disable-gpu',
'--window-size=2880,1800'
]
},
'moz:firefoxOptions': {
args: ['--headless']
}
},
jasmineNodeOpts: {
defaultTimeoutInterval: extendedDefaultTimeoutInterval,
isVerbose: true,
showTiming: true,
includeStackTrace: true,
realtimeFailure: true,
showColors: true
},
suites: {
regression: [
// login logout tests
testBaseDir + 'login.test.js',
],
/**
* This suite is for development environment and always all dev tests will be executed.
*/
development: [
testBaseDir + 'dev1.js',
testBaseDir + 'dev2.js'
]
},
onCleanUp: function (results) {
retry.onCleanUp(results);
},
onPrepare() {
retry.onPrepare();

//console.log('Running instance at '+ new Date());
jasmine.getEnv().addReporter(new SpecReporter({
  displayStacktrace: true,
  displaySpecDuration: true,
  displaySuiteNumber: true
}));


browser.manage().timeouts().pageLoadTimeout(pageLoadTimeout);
browser.manage().timeouts().implicitlyWait(2000);

let jasmineReporters = require('jasmine-reporters');
let junitReporter = new jasmineReporters.JUnitXmlReporter({
  savePath: protractorPath,

  // conslidate all true:
  //   output/junitresults.xml
  //
  // conslidate all set to false:
  //   output/junitresults-example1.xml
  //   output/junitresults-example2.xml
  consolidateAll: true
});

jasmine.getEnv().addReporter(new JSONReporter({
  file: 'target/jasmine-results.json', // by default it writes to jasmine.json
  beautify: true,
  indentationLevel: 4 // used if beautify === true
}));

jasmine.getEnv().addReporter(junitReporter);

var AllureReporter = require('jasmine-allure-reporter');
jasmine.getEnv().addReporter(new AllureReporter({
  resultsDir: 'target/allure-results'
}));
jasmine.getEnv().afterEach(function(done){
  browser.takeScreenshot().then(function (png) {
    allure.createAttachment('Screenshot', function () {
      return new Buffer(png, 'base64')
    }, 'image/png')();
    done();
  })
});

//browser.driver.manage().window().maximize(); // disable for Mac OS
browser.get(browser.baseUrl);
return browser.wait(() => {
  return browser.getCurrentUrl().then(url => {
    return /login/.test(url);
  });
}, pageResolveTimeout);

},
beforeLaunch: function () {

},
afterLaunch: function() {

return retry.afterLaunch(maxRetryForFailedTests);

}
};
`

Please help me , I am stuck

@Syslog2905
Copy link

Syslog2905 commented Jun 11, 2019

Guys & girls, seems like I have just found a workaroung, not very nice but at least working:
webdriver-manager clean
webdriver-manager update
and you are ready to go!

@shtlrs
Copy link

shtlrs commented Jan 29, 2021

I've been through this case before.
The issue was that one of my tests ( since I was running them in // ) was hanging because of a explicit waiting condition that had a very big timeout value.
So what I'd advise you to do is, run them in // ( Here's how to do it [https://stackoverflow.com/a/38694255/10273452]) and put maxInstances = 1 and try to identify the tests that's causing the hanging.
Good luck !

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