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

Jenkins Pipeline Error "Cannot create BrowserWindow before app is ready" #918

Closed
wichopy opened this issue Nov 15, 2017 · 17 comments
Closed
Labels
CI General issues involving running in a CI provider OS: mac

Comments

@wichopy
Copy link

wichopy commented Nov 15, 2017

Is this a Feature or Bug?

Bug

Current behavior:

Running Cypress on a Jenkins build pipeline returns the following error:

Cannot create BrowserWindow before app is ready
Error: Cannot create BrowserWindow before app is ready
    at Error (native)
    at Object._newBrowserWindow (/Users/web/Library/Jenkins/workspace/ontinuous-integration-setup-XUUWEDMZSZATM5VNREUERBR2OSTUGL6EADKBRHDOVCDZRWLEB7LQ/node_modules/cypress/dist/Cypress.app/Contents/Resources/app/packages/server/lib/gui/windows.js:90:14)
    at Object.create (/Users/web/Library/Jenkins/workspace/ontinuous-integration-setup-XUUWEDMZSZATM5VNREUERBR2OSTUGL6EADKBRHDOVCDZRWLEB7LQ/node_modules/cypress/dist/Cypress.app/Contents/Resources/app/packages/server/lib/gui/windows.js:183:18)
    at Object._render (/Users/web/Library/Jenkins/workspace/ontinuous-integration-setup-XUUWEDMZSZATM5VNREUERBR2OSTUGL6EADKBRHDOVCDZRWLEB7LQ/node_modules/cypress/dist/Cypress.app/Contents/Resources/app/packages/server/lib/browsers/electron.js:60:21)
    at /Users/web/Library/Jenkins/workspace/ontinuous-integration-setup-XUUWEDMZSZATM5VNREUERBR2OSTUGL6EADKBRHDOVCDZRWLEB7LQ/node_modules/cypress/dist/Cypress.app/Contents/Resources/app/packages/server/lib/browsers/electron.js:108:24
    at tryCatcher (/Users/web/Library/Jenkins/workspace/ontinuous-integration-setup-XUUWEDMZSZATM5VNREUERBR2OSTUGL6EADKBRHDOVCDZRWLEB7LQ/node_modules/cypress/dist/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/web/Library/Jenkins/workspace/ontinuous-integration-setup-XUUWEDMZSZATM5VNREUERBR2OSTUGL6EADKBRHDOVCDZRWLEB7LQ/node_modules/cypress/dist/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:510:31)
    at Promise._settlePromise (/Users/web/Library/Jenkins/workspace/ontinuous-integration-setup-XUUWEDMZSZATM5VNREUERBR2OSTUGL6EADKBRHDOVCDZRWLEB7LQ/node_modules/cypress/dist/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:567:18)
    at Promise._settlePromise0 (/Users/web/Library/Jenkins/workspace/ontinuous-integration-setup-XUUWEDMZSZATM5VNREUERBR2OSTUGL6EADKBRHDOVCDZRWLEB7LQ/node_modules/cypress/dist/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:612:10)
    at Promise._settlePromises (/Users/web/Library/Jenkins/workspace/ontinuous-integration-setup-XUUWEDMZSZATM5VNREUERBR2OSTUGL6EADKBRHDOVCDZRWLEB7LQ/node_modules/cypress/dist/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:691:18)
    at Async._drainQueue (/Users/web/Library/Jenkins/workspace/ontinuous-integration-setup-XUUWEDMZSZATM5VNREUERBR2OSTUGL6EADKBRHDOVCDZRWLEB7LQ/node_modules/cypress/dist/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:133:16)
    at Async._drainQueues (/Users/web/Library/Jenkins/workspace/ontinuous-integration-setup-XUUWEDMZSZATM5VNREUERBR2OSTUGL6EADKBRHDOVCDZRWLEB7LQ/node_modules/cypress/dist/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:143:10)
    at Immediate.Async.drainQueues (/Users/web/Library/Jenkins/workspace/ontinuous-integration-setup-XUUWEDMZSZATM5VNREUERBR2OSTUGL6EADKBRHDOVCDZRWLEB7LQ/node_modules/cypress/dist/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:574:20)
    at tryOnImmediate (timers.js:554:5)
    at processImmediate [as _immediateCallback] (timers.js:533:5)

Desired behavior:

Run cypress as part of the testing stage in Jenkins pipeline.

  • Operating System: MacOS 10.12.6
  • Cypress Version: 1.0.3
@bahmutov
Copy link
Contributor

Interesting, how can we recreate this failure? Is there a small example public repository that shows this behavior?

@jennifer-shehane jennifer-shehane added stage: needs information Not enough info to reproduce the issue CI: jenkins labels Nov 16, 2017
@wichopy
Copy link
Author

wichopy commented Nov 17, 2017

My tests started running randomly but then this issue came up again. After looking into it more, I noticed the tests started working after changing the way I was defining env vars in my Jenkinsile. I made dynamic env vars with bash scripts grabbing the current branch name and date for naming reports that I am autogenerating.

When ran a simple cypress run with no extra arguments, my tests started running again.

With Jenkin's crazy idiosynchrasies I think I will find another way to get this information or just have simpler report titles... this caused too many headaches for me.

@wichopy wichopy changed the title Jenkins pipeline errors out when attempting to run cypress tests. Jenkins Pipeline Error "Cannot create BrowserWindow before app is ready" Nov 17, 2017
@joelgrimberg
Copy link

joelgrimberg commented Jan 18, 2018

Just found out that I have the same problem. I will try to reproduce it in a public repo.

possibly related:
meetalva/alva#137

has somebody found a workaround?

@wichopy
Copy link
Author

wichopy commented Jan 18, 2018

Funny enough I got this error again yesterday evening when we reset our build server. This time I notice this in the logs before the ‘BrowserWindow’ error came up.

_RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL

@wichopy
Copy link
Author

wichopy commented Jan 18, 2018

I found this: https://issues.jenkins-ci.org/browse/JENKINS-23736

Last time I debugged this issue, I physically logged in on the machine and ran the cypress tests myself during debugging, and never logged off. I think this may be our answer, going to try it out when I get into work.

@wichopy
Copy link
Author

wichopy commented Jan 23, 2018

No luck with having the account logged in. I was able to run cypress manually but the automated cypress command doesn't work.

@wichopy
Copy link
Author

wichopy commented Jan 24, 2018

Seems like this error is specific to MacOS, ran on our Jenkins server running on Ubuntu and everything is working fine. Possible fix could be using Cypress's docker image?

https://github.com/cypress-io/cypress-docker-images

@sonchau
Copy link

sonchau commented Jul 30, 2018

Same issue on Mac High Sierra v10.13.6
Working fine on Ubuntu 18.04

@msilesgap
Copy link

I've Mojave 10.14.2 (18C54) and I'm still getting the same problem. I have Jenkins locally installed on my mac and I want to run the sample tests

npm WARN prepare removing existing node_modules/ before installation

> cypress@3.1.4 postinstall /Users/Shared/Jenkins/Home/workspace/CypressTraining/node_modules/cypress
> node index.js --exec install


Cypress 3.1.4 is installed in /Users/Shared/Jenkins/Library/Caches/Cypress/3.1.4

added 197 packages in 5.763s
+ ./node_modules/.bin/cypress run
_RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.
2019-01-13 18:55:43.427 Cypress[6401:664446] +[NSXPCSharedListener endpointForReply:withListenerName:]: an error occurred while attempting to obtain endpoint for listener 'ClientCallsAuxiliary': Connection interrupted

================================================================================

  (Run Starting)

  ┌────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:  3.1.4                                                            │
  │ Browser:  Electron 59 (headless)                                           │
  │ Specs:    20 found (examples/actions.spec.js, examples/aliasing.spec.js, … │
  └────────────────────────────────────────────────────────────────────────────┘


────────────────────────────────────────────────────────────────────────────────
                                                                                
  Running: examples/actions.spec.js...                                (1 of 20) 
Cannot create BrowserWindow before app is ready
Error: Cannot create BrowserWindow before app is ready
    at Object._newBrowserWindow (/Users/Shared/Jenkins/Library/Caches/Cypress/3.1.4/Cypress.app/Contents/Resources/app/packages/server/lib/gui/windows.js:92:14)
    at Object.create (/Users/Shared/Jenkins/Library/Caches/Cypress/3.1.4/Cypress.app/Contents/Resources/app/packages/server/lib/gui/windows.js:195:18)
    at Object._render (/Users/Shared/Jenkins/Library/Caches/Cypress/3.1.4/Cypress.app/Contents/Resources/app/packages/server/lib/browsers/electron.js:87:21)
    at /Users/Shared/Jenkins/Library/Caches/Cypress/3.1.4/Cypress.app/Contents/Resources/app/packages/server/lib/browsers/electron.js:213:24
    at <anonymous>:null:null

Build step 'Execute shell' marked build as failure
Finished: FAILURE

@jennifer-shehane
Copy link
Member

Can you attempt to follow these directions? May be related to Jenkins permissions issues https://stackoverflow.com/a/21028195/5878476

@jennifer-shehane jennifer-shehane added stage: awaiting response Potential fix was proposed; awaiting response and removed stage: needs information Not enough info to reproduce the issue labels Jan 30, 2019
@Light07
Copy link

Light07 commented May 23, 2019

Can you attempt to follow these directions? May be related to Jenkins permissions issues https://stackoverflow.com/a/21028195/5878476

Probably not related to permission, I did whatever this thread suggesting me but got no lucky.

@asans
Copy link

asans commented Jun 26, 2019

I'm attempting to run some cypress tests on SemaphoreCI within their OSX environment and am encountering this issue as well.

OSX : 10.14.5
Kernel: Darwin 18.6.0

When running "cypress run", the following error shows:

_RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.
2019-06-26 05:07:07.441 Cypress[5288:16143] +[NSXPCSharedListener endpointForReply:withListenerName:]: an error occurred while attempting to obtain endpoint for listener 'ClientCallsAuxiliary': Connection interrupted

====================================================================================================

  (Run Starting)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:    3.3.1                                                                              │
  │ Browser:    Electron 61 (headless)                                                             │
  │ Specs:      1 found (swithing_views_spec.js)                                       │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


────────────────────────────────────────────────────────────────────────────────────────────────────

  Running: swithing_views_spec.js...                                           (1 of 1)
Cannot create BrowserWindow before app is ready
Error: Cannot create BrowserWindow before app is ready
    at Object._newBrowserWindow (/Users/semaphore/Library/Caches/Cypress/3.3.1/Cypress.app/Contents/Resources/app/packages/server/lib/gui/windows.js:104:14)
    at Object.create (/Users/semaphore/Library/Caches/Cypress/3.3.1/Cypress.app/Contents/Resources/app/packages/server/lib/gui/windows.js:207:18)
    at Object._render (/Users/semaphore/Library/Caches/Cypress/3.3.1/Cypress.app/Contents/Resources/app/packages/server/lib/browsers/electron.js:87:21)
    at /Users/semaphore/Library/Caches/Cypress/3.3.1/Cypress.app/Contents/Resources/app/packages/server/lib/browsers/electron.js:214:24
    at <anonymous>:null:null

After searching around, I haven't found a way to get this to work. So I resorted to installing Chrome, ie brew install caskroom/cask/google-chrome. This installed Chrome 75 as of this writing.

After installing Chrome into /Applications, I then run cypress run -b chrome, which it was able to run the test with the full log output here:

_RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.
2019-06-26 05:02:24.244 Cypress[5215:15122] In void modifyShouldRestoreOnRelaunchCounter(int32_t), _LSSetApplicationInformationItem(_kLSPersistenceSuppressRelaunchAtLoginKey) returned error -600
2019-06-26 05:02:24.346 Cypress[5215:14970] +[NSXPCSharedListener endpointForReply:withListenerName:]: an error occurred while attempting to obtain endpoint for listener 'ClientCallsAuxiliary': Connection interrupted

====================================================================================================

  (Run Starting)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:    3.3.1                                                                              │
  │ Browser:    Chrome 75                                                                          │
  │ Specs:      1 found (swithing_views_spec.js)                                       │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


────────────────────────────────────────────────────────────────────────────────────────────────────

  Running: swithing_views_spec.js...                                           (1 of 1)

Warning: Cypress can only record videos when using the built in 'electron' browser.

You have set the browser to: 'chrome'

A video will not be recorded when using this browser.

So it appears that one is actually able to run the test, but it's just not able to run the test using electron chromium browser, but it's able to run it using the external Chrome app.

This now appears to be more of a Cypress issue more so than SemaphoreCI's OSX. It also appears that the errors are different between running under electron vs chrome.

@jennifer-shehane jennifer-shehane added stage: needs information Not enough info to reproduce the issue and removed stage: awaiting response Potential fix was proposed; awaiting response labels Jul 11, 2019
@bahmutov
Copy link
Contributor

Could be old Electron version issue, I wonder if Electron upgrade in #4355 or #4354 fixes this.

I will add Mac build to the Semaphore v2 CI project in https://github.com/cypress-io/cypress-example-kitchensink to see if we can recreate the problem - and to confirm that Electron upgrade fixes it when it is released

@bahmutov
Copy link
Contributor

I have set up Mac CI build cypress-io/cypress-example-kitchensink#269, it is showing the problem, let's recheck after upgrading Electron version

@jennifer-shehane
Copy link
Member

Since this issue hasn't had activity in a while, we'll close the issue until we can confirm this is still happening. Please comment if there is new information to provide concerning the original issue and we'd be happy to reopen.

@jennifer-shehane jennifer-shehane removed the stage: needs information Not enough info to reproduce the issue label Feb 3, 2021
@msabramo
Copy link

I am running into this now on a Mac OS X Catalina 10.15.6 machine with Cypress 6.3.0 where previously the Cypress tests had been running fine for months. Here's the output:

+ CYPRESS_BASEURL=http://localhost:56670
+ npx cypress run --config baseUrl=http://localhost:56670 --reporter junit --reporter-options 'mochaFile=results/junit-[hash].xml'
2021-03-29 12:04:24.676 Cypress[12101:927427] In void modifyShouldRestoreOnRelaunchCounter(int32_t), _LSSetApplicationInformationItem(_kLSPersistenceSuppressRelaunchAtLoginKey) returned error -600
2021-03-29 12:04:25.486 Cypress[12101:927427] +[NSXPCSharedListener endpointForReply:withListenerName:]: an error occurred while attempting to obtain endpoint for listener 'ClientCallsAuxiliary': Connection interrupted
Couldn't find tsconfig.json. tsconfig-paths will be skipped

====================================================================================================

  (Run Starting)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:    6.3.0                                                                              │
  │ Browser:    Electron 87 (headless)                                                             │
  │ Specs:      16 found (add_analyzers_in_url.js, auto_tag.spec.js, autoCropv3.spec.js, chain_aut │
  │             oCropv3_textPlacement.spec.js, chain_textPlacement_autoCropv3.spec.js, input_image │
  │             _pane.spec.js, logo_detection.spec.js, ms_ocr.spec.js, object_detector.spec.js, pr │
  │             emium_class...)                                                                    │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


────────────────────────────────────────────────────────────────────────────────────────────────────

  Running:  add_analyzers_in_url.js                                                        (1 of 16)
Cannot create BrowserWindow before app is ready
Error: Cannot create BrowserWindow before app is ready
    at _newBrowserWindow (/Users/admin/Library/Caches/Cypress/6.3.0/Cypress.app/Contents/Resources/app/packages/server/lib/gui/windows.js:102:12)
    at Object.create (/Users/admin/Library/Caches/Cypress/6.3.0/Cypress.app/Contents/Resources/app/packages/server/lib/gui/windows.js:147:15)
    at Object._render (/Users/admin/Library/Caches/Cypress/6.3.0/Cypress.app/Contents/Resources/app/packages/server/lib/browsers/electron.js:161:25)
    at /Users/admin/Library/Caches/Cypress/6.3.0/Cypress.app/Contents/Resources/app/packages/server/lib/browsers/electron.js:366:19
    at tryCatcher (/Users/admin/Library/Caches/Cypress/6.3.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/admin/Library/Caches/Cypress/6.3.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/Users/admin/Library/Caches/Cypress/6.3.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/Users/admin/Library/Caches/Cypress/6.3.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/Users/admin/Library/Caches/Cypress/6.3.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:729:18)
    at _drainQueueStep (/Users/admin/Library/Caches/Cypress/6.3.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/Users/admin/Library/Caches/Cypress/6.3.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/Users/admin/Library/Caches/Cypress/6.3.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/admin/Library/Caches/Cypress/6.3.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (internal/timers.js:456:21)

@msabramo
Copy link

And now strangely, after not working several times in a row, I just ran again and it worked.

Two possibilities come to mind:

  1. It's totally random whether it fails or passes, as it's due to some race condition or intermittent issue.
  2. One thing I did before running again this time is I open a Screen Sharing session to the Mac server and logged in (I was already logged in with SSH, so clearly that is not sufficient). I was logged out, I think because the server was rebooted recently. I wonder if for some reason the electron browser is dependent on some user being logged in to the GUI (not just SSH)?

@jennifer-shehane jennifer-shehane added CI General issues involving running in a CI provider and removed CI: jenkins labels Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI General issues involving running in a CI provider OS: mac
Projects
None yet
Development

No branches or pull requests

9 participants