spectron icon indicating copy to clipboard operation
spectron copied to clipboard

ChromeDriver did not start with Spectron 11.1.0

Open TimTalis opened this issue 3 years ago • 14 comments

TimTalis avatar Jul 10 '20 13:07 TimTalis

I am also getting same issue with electron 9

hrishabhkumar avatar Jul 17 '20 06:07 hrishabhkumar

I am getting a similar issue but only in my CI environment. It is a very spastic bug that has been on and off since Electron 7/Spectron 9. Tests run fine locally, but as soon as they run in GitHub actions chromedriver will randomly decide to not start. It does not seem to be a consistent test that fails either but jumps around. The weird thing is that sometimes one or two test will fail but then if the test suite is rerun later everything will pass just fine.

The error that always gets thrown is this:

Error: ChromeDriver did not start within 5000ms 
    at /home/runner/work/Communication-Manager-Electron/Communication Manager-Electron/node_modules/spectron/lib/chrome-driver.js:63:25
    at Request._callback (/home/runner/work/Communication-Manager-Electron/Communication-Manager-Electron/node_modules/spectron/lib/chrome-driver.js:121:23)
    at self.callback (/home/runner/work/Communication-Manager-Electron/Communication-Manager-Electron/node_modules/request/request.js:185:22)
    at Request.emit (events.js:315:20)
    at Request.EventEmitter.emit (domain.js:482:12)
    at Request.onRequestError (/home/runner/work/Communication-Manager-Electron/Communication-Manager-Electron/node_modules/request/request.js:877:8)
    at ClientRequest.emit (events.js:315:20)
    at ClientRequest.EventEmitter.emit (domain.js:482:12)
    at Socket.socketErrorListener (_http_client.js:426:9)
    at Socket.emit (events.js:315:20)
    at Socket.EventEmitter.emit (domain.js:482:12)
    at emitErrorNT (internal/streams/destroy.js:92:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)

I don't really know where to start with troubleshooting since its so irregular.

Update:

I didn't realize that I was still only on spectron 11. Updating to 11.1.0 crashed everything. But changed the errors being throw entirely. Now every test throws this:

 TypeError: app.client.click is not a function
      at Context.<anonymous> (test/test_index.js:598:22)
      at processTicksAndRejections (internal/process/task_queues.js:93:5)

I see that there are other issues more similar to this and will post this there.

harrellbm avatar Jul 24 '20 23:07 harrellbm

Reproducible in the circleci/node:latest-browsers Docker image. Specifically, the error I receive is this:

  Application launch
    1) "before each" hook for "shows an initial window"


  0 passing (1s)
  1 failing

  1) Application launch
       "before each" hook for "shows an initial window":
     Error: Failed to create session.
unknown error: Chrome failed to start: exited abnormally.
  (unknown error: DevToolsActivePort file doesn't exist)

Interestingly, I can start chromedriver just fine:

$ chromedriver --whitelisted-ips=
Starting ChromeDriver 84.0.4147.30 (48b3e868b4cc0aa7e8149519690b6f6949e110a8-refs/branch-heads/4147@{#310}) on port 9515
All remote connections are allowed. Use a whitelist instead!
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.

Which leads me to believe this has something to do with WebdriverIO.

dlqqq avatar Aug 17 '20 22:08 dlqqq

This is happening with me as well. Any updates here?

twitharshil avatar Aug 24 '20 07:08 twitharshil

Also experiencing this.

jameskerr avatar Oct 07 '20 00:10 jameskerr

I've spent hours for finding the reason. For me, the reason was got dependency of webdriver. I've downgraded it from 11.7.0 to 11.5.1 (by changing package-lock.json) and now it works fine.

megahertz avatar Oct 12 '20 14:10 megahertz

@megahertz could you explain a bit more how you did that? I've tried editing package-lock.json but npm install resets it

adam-lynch avatar Oct 12 '20 15:10 adam-lynch

OK I figured it out, but it didn't help for me at all. If anyone else wants to try, replace this in your package-lock.json:

        "got": {
          "version": "11.7.0",
          "resolved": "https://registry.npmjs.org/got/-/got-11.7.0.tgz",
          "integrity": "sha512-7en2XwH2MEqOsrK0xaKhbWibBoZqy+f1RSUoIeF1BLcnf+pyQdDsljWMfmOh+QKJwuvDIiKx38GtPh5wFdGGjg==",

... with:

        "got": {
          "version": "11.5.1",
          "resolved": "https://registry.npmjs.org/got/-/got-11.5.1.tgz",
          "integrity": "sha512-reQEZcEBMTGnujmQ+Wm97mJs/OK6INtO6HmLI+xt3+9CvnRwWjXutUvb2mqr+Ao4Lu05Rx6+udx9sOQAmExMxA==",

"got" is mentioned a few times but it seems that's the place that needs to be changed in order for npm install to grab the right version. I got the integrity value from https://registry.npmjs.org/got/11.5.1

adam-lynch avatar Oct 12 '20 15:10 adam-lynch

@adam-lynch, npm install => npm ci. If someone runs yarn, there is resolutions package.json section for this purpose.

vladimiry avatar Oct 12 '20 15:10 vladimiry

    "webdriver": {
      "version": "6.5.0",
      "resolved": "https://registry.npmjs.org/webdriver/-/webdriver-6.5.0.tgz",
      "integrity": "sha512-6iOll9TshD4+2J+em+bLshvM1uXtnotdZ+JaALqRLbkVswLRFU0pTVP1oug0e/IYwL7Me4Cafh9ugQ4PwPuOnA==",
      "dev": true,
      "requires": {
        "@wdio/config": "6.4.7",
        "@wdio/logger": "6.4.7",
        "@wdio/protocols": "6.3.6",
        "@wdio/utils": "6.5.0",
        "lodash.merge": "^4.6.1"
      },
      "dependencies": {
        ...
        "got": {
          "version": "11.5.1"
        },
        ...

npm i

after that, npm ls got should show version 11.5.1 for got, in my case:

├─┬ [email protected]
│ └─┬ @electron/[email protected]
│   └── [email protected] 
└─┬ [email protected]
  └─┬ [email protected]
    └─┬ [email protected]
      └── [email protected] 

megahertz avatar Oct 12 '20 15:10 megahertz

@megahertz How did you find out that the problem was that dependency?

jesusiglesias avatar Oct 19 '20 08:10 jesusiglesias

@jesusiglesias I've traced until that place than replaced got by request (it works correctly), than tried got 11.5.1 instead of the latest

megahertz avatar Oct 19 '20 13:10 megahertz

I am also still seeing this in spectron v12 and v13

gilles-yvetot avatar Dec 17 '20 02:12 gilles-yvetot

Double check there is not an instance of chromedriver already running. If you try and invoke chromedriver directly it will error if this is the case and it will give you the port number it is trying to bind to. Kill this existing process and try again, this is what the issue was with mine.

reaandrew avatar May 14 '21 12:05 reaandrew