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

Failed to connect to Chrome Debugging Protocol #26711

Closed
atmullan opened this issue May 10, 2023 · 8 comments · Fixed by #27169
Closed

Failed to connect to Chrome Debugging Protocol #26711

atmullan opened this issue May 10, 2023 · 8 comments · Fixed by #27169
Assignees
Labels
Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team.

Comments

@atmullan
Copy link

atmullan commented May 10, 2023

Current behavior

Cypress Crashes when Cypress Har Generator is enabled (https://github.com/NeuraLegion/cypress-har-generator) with Electron Browser with Flag ELECTRON_EXTRA_LAUNCH_ARGS=--remote-debugging-port=9222

Logs:

npm run cypress:run -- cypress/config/localreact.config.js

> cloudranger-v2-cypress@1.0.0 cypress:run
> percy exec -t 350 -- node scripts/cypress.js cypress/config/localreact.config.js

[percy] Skipping visual tests
[percy] Error: Missing Percy token
[percy] Running "node scripts/cypress.js cypress/config/localreact.config.js"


DevTools listening on ws://127.0.0.1:56853/devtools/browser/0f66cba6-f00b-4862-b756-1b4362f52b21

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

  (Run Starting)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:        12.12.0                                                                        │
  │ Browser:        Electron 106 (headless)                                                        │
  │ Node Version:   v16.20.0 (C:\Program Files\nodejs\node.exe)                                    │
  │ Specs:          1 found (smoke-dash.spec.js)                                                   │
  │ Searched:       C:\Users\Tony Mullan\Documents\Project\QA - 0000-000 CloudRanger\TM08 - Automa │
  │                 tion\Protractor\cloudranger-v2-testing\Cypress\cypress\e2e\Group-0\1-General\s │
  │                 moke-dash.spec.js                                                              │
  │ Experiments:    experimentalMemoryManagement=true                                              │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


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

  Running:  smoke-dash.spec.js                                                              (1 of 1)


  1) "before all" hook for "Smoke Test Dashboard Page"

  0 passing (2s)
  1 failing

  1) CR Page Smoke Tests
       "before all" hook for "Smoke Test Dashboard Page":
     CypressError: `cy.task('recordHar')` failed with the following error:

> Failed to connect to Chrome Debugging Protocol

Possible reasons for failure:
  - Chrome not running in headless mode
  - Using Chrome version 58 or earlier
  - Inconsistent RDP configuration settings.

The stack trace for this error is:

https://on.cypress.io/api/task

Because this error occurred during a `before all` hook we are skipping all of the remaining tests.
      at <unknown> (http://localhost:56855/__cypress/runner/cypress_runner.js:150983:78)
      at tryCatcher (http://localhost:56855/__cypress/runner/cypress_runner.js:18744:23)
      at Promise._settlePromiseFromHandler (http://localhost:56855/__cypress/runner/cypress_runner.js:16679:31)
      at Promise._settlePromise (http://localhost:56855/__cypress/runner/cypress_runner.js:16736:18)
      at Promise._settlePromise0 (http://localhost:56855/__cypress/runner/cypress_runner.js:16781:10)
      at Promise._settlePromises (http://localhost:56855/__cypress/runner/cypress_runner.js:16857:18)
      at _drainQueueStep (http://localhost:56855/__cypress/runner/cypress_runner.js:13451:12)
      at _drainQueue (http://localhost:56855/__cypress/runner/cypress_runner.js:13444:9)
      at ../../node_modules/bluebird/js/release/async.js.Async._drainQueues (http://localhost:56855/__cypress/runner/cypress_runner.js:13460:5)
      at Async.drainQueues (http://localhost:56855/__cypress/runner/cypress_runner.js:13330:14)
  From Your Spec Code:
      at Context.eval (webpack:///C:/Users/Tony Mullan/Documents/Project/QA - 0000-000 CloudRanger/TM08 - Automation/Protractor/cloudranger-v2-testing/Cypress/node_modules/@neuralegion/cypress-har-generator/commands.js:1:1260)

  From Node.js Internals:
    Error: Failed to connect to Chrome Debugging Protocol

    Possible reasons for failure:
      - Chrome not running in headless mode
      - Using Chrome version 58 or earlier
      - Inconsistent RDP configuration settings.

    The stack trace for this error is:
        at V.<anonymous> (C:\Users\Tony Mullan\Documents\Project\QA - 0000-000 CloudRanger\TM08 - Automation\Protractor\cloudranger-v2-testing\Cypress\node_modules\@neuralegion\cypress-har-generator\dist\index.js:1:39760)
    at Generator.next (<anonymous>)
        at fulfilled (C:\Users\Tony Mullan\Documents\Project\QA - 0000-000 CloudRanger\TM08 - Automation\Protractor\cloudranger-v2-testing\Cypress\node_modules\tslib\tslib.js:164:62)
        at processTicksAndRejections (node:internal/process/task_queues:96:5)



[mochawesome] Report JSON saved to C:\Users\Tony Mullan\Documents\Project\QA - 0000-000 CloudRanger\TM08 - Automation\Protractor\cloudranger-v2-testing\Cypress\mochawesome-report\mochawesome_05102023_114250.json

Results Stats {
  suites: 1,
  tests: 1,
  passes: 0,
  pending: 0,
  skipped: 0,
  failures: 1,
  wallClockStartedAt: '2023-05-10T10:42:48.239Z',
  wallClockEndedAt: '2023-05-10T10:42:50.599Z',
  wallClockDuration: 2360
}
Finished running spec cypress\e2e\Group-0\1-General\smoke-dash.spec.js

  (Results)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Tests:        1                                                                                │
  │ Passing:      0                                                                                │
  │ Failing:      1                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  1                                                                                │
  │ Video:        true                                                                             │
  │ Duration:     2 seconds                                                                        │
  │ Spec Ran:     smoke-dash.spec.js                                                               │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


  (Screenshots)

  -  C:\Users\Tony Mullan\Documents\Project\QA - 0000-000 CloudRanger\TM08 - Automati     (1280x720)
     on\Protractor\cloudranger-v2-testing\Cypress\cypress\screenshots\smoke-dash.spec
     .js\Smoke Test Dashboard Page -- before all hook (failed).png


  (Video)

  -  Started processing:  Compressing to 32 CRF
  -  Finished processing: 0 seconds

  -  Video output: C:\Users\Tony Mullan\Documents\Project\QA - 0000-000 CloudRanger\TM08 - Automation\Protractor\cloudranger-v2-testing\Cypress\cypress\videos\smoke-dash.spec.js.mp4


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

  (Run Finished)


       Spec                                              Tests  Passing  Failing  Pending  Skipped  
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ ✖  smoke-dash.spec.js                       00:02        1        -        1        -        - │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
    ✖  1 of 1 failed (100%)                     00:02        1        -        1        -        -  

Desired behavior

Works Fine in Previous Cypress Releases

Test code to reproduce

Run a spec with Electron and Cypress Har Generator enabled

cy.recordHar({ includeMimes: ['application/json'] })

Cypress Version

12.12.0

Node version

v16.20.0

Operating System

Windows and Ubuntu

Debug Logs

No response

Other

No response

@aaron-qa
Copy link

aaron-qa commented Jun 1, 2023

Also seeing this issue on v12.12 but not on v12.11.

@derevnjuk
Copy link

Do you have any updates on it, @warrensplayer?

@warrensplayer
Copy link
Contributor

@atmullan @derevnjuk Looking at this issue today. Sorry for the delay.

@warrensplayer
Copy link
Contributor

@atmullan @derevnjuk I am not able to reproduce your error with your example repo.

My steps:

I did do not see the same files or output that you show in the description above. Are you able to reproduce the error with the example directory here: https://github.com/NeuraLegion/cypress-har-generator ?

stokes@H3QGMW7Y6L example % export ELECTRON_EXTRA_LAUNCH_ARGS=--remote-debugging-port=9222             
stokes@H3QGMW7Y6L example % npm run cypress:run                                                        

> cypress-har-generator-demo@1.0.0 cypress:run
> cypress run --browser chrome --headless

[83010:0628/095638.962069:ERROR:node_bindings.cc(279)] Most NODE_OPTIONs are not supported in packaged apps. See documentation for more details.
[83010:0628/095638.962092:ERROR:node_bindings.cc(279)] Most NODE_OPTIONs are not supported in packaged apps. See documentation for more details.
[83010:0628/095638.962096:ERROR:node_bindings.cc(279)] Most NODE_OPTIONs are not supported in packaged apps. See documentation for more details.

DevTools listening on ws://127.0.0.1:9222/devtools/browser/9eca2e71-7395-4ebe-807c-8a38c0b390cf
Missing baseUrl in compilerOptions. tsconfig-paths will be skipped

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

  (Run Starting)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:        12.3.0                                                                         │
  │ Browser:        Chrome 114 (headless)                                                          │
  │ Node Version:   v16.18.1 (/Users/stokes/.nvm/versions/node/v16.18.1/bin/node)                  │
  │ Specs:          2 found (logging-in-xhr-web-form.cy.ts, logging-via-request.cy.ts)             │
  │ Searched:       cypress/integration/**/*.cy.ts                                                 │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


────────────────────────────────────────────────────────────────────────────────────────────────────
                                                                                                    
  Running:  logging-in-xhr-web-form.cy.ts                                                   (1 of 2)


  Logging In - XHR Web Form
    XHR form submission
      ✓ successfully logs in (680ms)
      ✓ displays errors on login (547ms)
      ✓ can stub the XHR to force it to fail (536ms)
      ✓ redirects to /dashboard on success (587ms)
      ✓ redirects on a stubbed XHR (594ms)


  5 passing (3s)


  (Results)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Tests:        5                                                                                │
  │ Passing:      5                                                                                │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        false                                                                            │
  │ Duration:     2 seconds                                                                        │
  │ Spec Ran:     logging-in-xhr-web-form.cy.ts                                                    │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


────────────────────────────────────────────────────────────────────────────────────────────────────
                                                                                                    
  Running:  logging-via-request.cy.ts                                                       (2 of 2)


  Logging in using XHR request
    ✓ can bypass the UI and yet still log in (92ms)


  1 passing (113ms)


  (Results)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Tests:        1                                                                                │
  │ Passing:      1                                                                                │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        false                                                                            │
  │ Duration:     0 seconds                                                                        │
  │ Spec Ran:     logging-via-request.cy.ts                                                        │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


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

  (Run Finished)


       Spec                                              Tests  Passing  Failing  Pending  Skipped  
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ ✔  logging-in-xhr-web-form.cy.ts            00:02        5        5        -        -        - │
  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ ✔  logging-via-request.cy.ts                112ms        1        1        -        -        - │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
    ✔  All specs passed!                        00:03        6        6        -        -        -  

@derevnjuk
Copy link

derevnjuk commented Jun 28, 2023

@warrensplayer, it seems that you are using version 12.3.0, but the issue can be reproduced starting from version 12.12.0. Please update Cypress to the latest version in the example folder and then repeat the steps.

Also, it appears that you are still launching tests on Chrome. Please update the example/package.json as follows:

-    "cypress:run": "cypress run --browser chrome --headless",
+    "cypress:run": "cypress run --browser electron",
    "start": "node -r ts-node/register src/index.ts --port 7079",
    "test": "start-test 7079 cypress:run"

Thanks 😉

@warrensplayer
Copy link
Contributor

Thanks for clarifying. I was just using the default files in your repo and missed the specifics in your output. I was able to reproduce the error. Looking at it a bit more to see if I can find a simple fix.

@warrensplayer
Copy link
Contributor

@derevnjuk I found the update that broke this functionality. It was the PR: #26573 that was part of the 12.12.0 release. The new code was overriding the the debug port being sent in via the environment variable.

I have a simple fix and will work on getting a PR up for it shortly.

@warrensplayer warrensplayer added the Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. label Jun 29, 2023
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jul 6, 2023

Released in 12.17.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v12.17.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Jul 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants