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

Cypress headless hangs in second spec after previous goes back in history #5475

Closed
dwelle opened this issue Oct 25, 2019 · 14 comments · Fixed by #5849
Closed

Cypress headless hangs in second spec after previous goes back in history #5475

dwelle opened this issue Oct 25, 2019 · 14 comments · Fixed by #5849
Labels
browser: electron type: regression A bug that didn't appear until a specific Cy version release v3.5.0 🐛 Issue present since 3.5.0

Comments

@dwelle
Copy link

dwelle commented Oct 25, 2019

Current behavior:

In headless electron (headed electron works fine), the process hangs forever when doing the below steps.

Basically, you do something like this in a.spec.js:

cy.visit(`https://google.com`)
cy.window().then(win => {
  win.history.pushState({}, null, `/`)
});
cy.go(-1);

and in b.spec.js you retrieve an elem:

cy.get('.item');

I know that the 2nd spec file isn't really a valid use case (since we haven't yet loaded a page), but I've wanted to create the smallest reproducible test case.

I'm not really sure what's going on, but there are several significant things that must be done:

  1. load some page

  2. push a new state to history

  3. go back window.location.go(-1)

  4. and in the next spec (must be a different file so that Cypress runner closes & opens new window), retrieve a DOM elem.

    This last step is weird because before I managed to narrow it down to this smallest reproduction, I've been doing much more in my real-world spec, and it failed only on one particular DOM retrieval. Don't have a clue, but it also reproduces when I simply query the DOM, without loading a page.

  5. hangs, forever (?). DEBUG=cypress:* doesn't show anything interesting, I think --- no new messages are logged after it hangs.

Desired behavior:

Should not hang.

Steps to reproduce: (app code and test code)

https://github.com/dwelle/cypress-test-tiny/tree/dwelle_hang

and run:

npx cypress run --spec cypress/integration/a.spec.js,cypress/integration/b.spec.js

The url links to the branch directly. Refer to README, if need be.

Versions

  • cypress 3.5.0 (3.4.1 works)
  • Win 7
@jennifer-shehane
Copy link
Member

jennifer-shehane commented Oct 28, 2019

I can confirm, this hangs forever during cypress run (does not happen when --browser chrome. This does not hang in 3.4.1.

I had to manually close the Cypress application to get it to stop running.

DEBUG logs at hang

 cypress:server:project received runnables { id: 'r1', title: '', root: true, type: 'suite', tests: [ { id: 'r2', title: 'history get item', body: "function () {\n  cy.get('.item');\n}", type: 'test' } ], suites: [] } +813ms
  cypress:server:reporter trying to load reporter: spec +2s
  cypress:server:reporter spec is Mocha reporter +0ms
  cypress:server:project onMocha start +5ms
  cypress:server:reporter got mocha event 'start' with args: [ { start: '2019-10-28T16:27:19.404Z' } ] +5ms

  cypress:server:project onMocha suite +1ms
  cypress:server:reporter got mocha event 'suite' with args: [ { id: 'r1', title: '', root: true, type: 'suite' } ] +1ms

  cypress:server:project onMocha test +24ms
  cypress:server:reporter got mocha event 'test' with args: [ { id: 'r2', title: 'history get item', body: "function () {\n  cy.get('.item');\n}", type: 'test' } ] +24ms
  cypress:server:socket automation:request get:cookies { domain: 'localhost' } +63ms
  cypress:server:cookies getting:cookies { domain: 'localhost' } +5s
  cypress:server:cookies received get:cookies [] +1ms
cypress:browserify finished bundling: /Users/jennifer/Library/Application Support/Cypress/cy/production/projects/cypress-transform-test-74d5161f4a1005f86b0d85a657ddcf07/bundles/cypress/integration/spec2.js +16ms
  cypress:server:controllers:spec sending spec { filePath: '/Users/jennifer/Library/Application Support/Cypress/cy/production/projects/cypress-transform-test-74d5161f4a1005f86b0d85a657ddcf07/bundles/cypress/integration/spec2.js' } +10ms
  cypress:server:project received runnables { id: 'r1', title: '', root: true, type: 'suite', tests: [ { id: 'r2', title: 'history get item', body: "function () {\n  cy.get('.item');\n}", type: 'test' } ], suites: [] } +813ms
  cypress:server:reporter trying to load reporter: spec +2s
  cypress:server:reporter spec is Mocha reporter +0ms
  cypress:server:project onMocha start +5ms
  cypress:server:reporter got mocha event 'start' with args: [ { start: '2019-10-28T16:27:19.404Z' } ] +5ms

  cypress:server:project onMocha suite +1ms
  cypress:server:reporter got mocha

specfile1.js

it('history go', () => {
  cy.visit(`https://google.com`)
  cy.window().then(win => {
    win.history.pushState({}, null, `/`)
  });
  cy.go('back');
})

specfile2.js

it('history get item', () => {
  cy.get('.item')
})

Workaround

Run tests in cypress run with the --browser flag specifying an installed version of Chrome.

@jennifer-shehane jennifer-shehane added type: regression A bug that didn't appear until a specific Cy version release browser: electron labels Oct 28, 2019
@cypress-bot cypress-bot bot added the stage: needs investigating Someone from Cypress needs to look at this label Oct 28, 2019
@psoares-resilient
Copy link

psoares-resilient commented Oct 29, 2019

Hi, just updated to the 3.5.0 as well and the same behaviour happens.

 Cypress:    3.5.0                                                                              │
  │ Browser:    Electron 73                                                                          │
  │ Specs:      6 found (data/investigate.spec.ts, data/missing-numbers.spec.ts, data/pagination.s │
  │             pec.ts, data/search.spec.ts, data/sort.spec.ts, data/text-filter.spec.ts)          │
  │ Searched:   cypress/integration/data/* 

In our case, it is always hanging after the first it in the second matched spec (whatever order it may be). Switching to chrome ( 72) also let the tests continue.

@dwelle
Copy link
Author

dwelle commented Oct 31, 2019

Can we get an update on this? It's a blocking regression that prevents from upgrading from 3.4.1 (I don't know of any workaround).

@cormack00
Copy link

Is there any chance this will be fixed in 3.6.1? Causing issues here too.

@jinder
Copy link

jinder commented Nov 8, 2019

I think this is a broader issue than the comment suggests - HTML5 navigation in general seems to cause Cypress to hang.

@jennifer-shehane
Copy link
Member

Maybe related: #5645

@jennifer-shehane
Copy link
Member

Also likely related: #5596

@brian-mann
Copy link
Member

I spent a few hours debugging this - I believe it is a bug in electron core. I have tried dozens of different possible workarounds involving clearing session, cache, partitions, etc and nothing is working as of yet.

@brian-mann
Copy link
Member

Confirmed this is a bug in electron. It is still failing in 6.1.5 but it is working in 7.1.2.

Looks like we can fix this by upgrading electron.

@flotwig flotwig mentioned this issue Dec 2, 2019
3 tasks
@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review and removed stage: needs investigating Someone from Cypress needs to look at this labels Dec 8, 2019
@jennifer-shehane jennifer-shehane changed the title Cypress headless hangs in second spec after previous goes back in history 3.5.0 Cypress headless hangs in second spec after previous goes back in history Dec 10, 2019
@jennifer-shehane jennifer-shehane added the v3.5.0 🐛 Issue present since 3.5.0 label Dec 10, 2019
@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Dec 11, 2019
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Dec 11, 2019

The code for this is done in cypress-io/cypress#5849, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@jennifer-shehane
Copy link
Member

Released in 3.8.0.

@raghugitrepo
Copy link

@jennifer-shehane sorry for commenting on closed ticket. I am kind of facing similar issue running tests in docker. After the first test spec cypress hangs on forever.
I am using "cypress/browsers:node13.6.0-chrome80-ff72" image. Also pasting the logs of cypress in debug mode.

[34;1mcypress:server:browsers:chrome �[0mconnecting to Chrome remote interface at random port 44619 �[34m+15ms�[0m
�[33;1mcypress:server:protocol �[0mGetting WS connection to CRI on port 44619 �[33m+2s�[0m
�[31;1mcypress:launcher �[0mchrome stderr: [2265:2280:0423/035613.707142:ERROR:bus.cc(393)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory �[31m+148ms�[0m
�[32;1mcypress:network:connect �[0mreceived error on connect, retrying { iteration: �[33m0�[39m, delay: �[33m100�[39m, err: Error: connect ECONNREFUSED 127.0.0.1:44619 �[90m at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1128:14)�[39m { errno: �[32m'ECONNREFUSED'�[39m, code: �[32m'ECONNREFUSED'�[39m, syscall: �[32m'connect'�[39m, address: �[32m'127.0.0.1'�[39m, port: �[33m44619�[39m } } �[32m+260ms�[0m
�[31;1mcypress:launcher �[0mchrome stderr: [2265:2265:0423/035613.708675:ERROR:edid_parser.cc(102)] Too short EDID data: manufacturer id �[31m+1ms�[0m
�[31;1mcypress:launcher �[0mchrome stderr: [2265:2289:0423/035613.731195:ERROR:bus.cc(393)] Failed to connect to the bus: Address does not contain a colon �[31m+23ms�[0m
�[31;1mcypress:launcher �[0mchrome stderr: DevTools listening on ws://127.0.0.1:44619/devtools/browser/bf00290b-61c9-4229-808a-d016583652d7 �[31m+7ms�[0m
�[31;1mcypress:launcher �[0mchrome stderr: [2265:2289:0423/035613.741804:ERROR:bus.cc(393)] Failed to connect to the bus: Address does not contain a colon
[2265:2289:0423/035613.741826:ERROR:bus.cc(393)] Failed to connect to the bus: Address does not contain a colon �[31m+4ms�[0m
�[31;1mcypress:server:server �[0mGot CONNECT request from www.gstatic.com:443 �[31m+234ms�[0m

@ycwdaaaa
Copy link

@jennifer-shehane sorry for commenting on closed ticket. I am kind of facing similar issue running tests in docker. After the first test spec cypress hangs on forever.
I am using "cypress/browsers:node13.6.0-chrome80-ff72" image. Also pasting the logs of cypress in debug mode.

[34;1mcypress:server:browsers:chrome �[0mconnecting to Chrome remote interface at random port 44619 �[34m+15ms�[0m
�[33;1mcypress:server:protocol �[0mGetting WS connection to CRI on port 44619 �[33m+2s�[0m
�[31;1mcypress:launcher �[0mchrome stderr: [2265:2280:0423/035613.707142:ERROR:bus.cc(393)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory �[31m+148ms�[0m
�[32;1mcypress:network:connect �[0mreceived error on connect, retrying { iteration: �[33m0�[39m, delay: �[33m100�[39m, err: Error: connect ECONNREFUSED 127.0.0.1:44619 �[90m at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1128:14)�[39m { errno: �[32m'ECONNREFUSED'�[39m, code: �[32m'ECONNREFUSED'�[39m, syscall: �[32m'connect'�[39m, address: �[32m'127.0.0.1'�[39m, port: �[33m44619�[39m } } �[32m+260ms�[0m
�[31;1mcypress:launcher �[0mchrome stderr: [2265:2265:0423/035613.708675:ERROR:edid_parser.cc(102)] Too short EDID data: manufacturer id �[31m+1ms�[0m
�[31;1mcypress:launcher �[0mchrome stderr: [2265:2289:0423/035613.731195:ERROR:bus.cc(393)] Failed to connect to the bus: Address does not contain a colon �[31m+23ms�[0m
�[31;1mcypress:launcher �[0mchrome stderr: DevTools listening on ws://127.0.0.1:44619/devtools/browser/bf00290b-61c9-4229-808a-d016583652d7 �[31m+7ms�[0m
�[31;1mcypress:launcher �[0mchrome stderr: [2265:2289:0423/035613.741804:ERROR:bus.cc(393)] Failed to connect to the bus: Address does not contain a colon
[2265:2289:0423/035613.741826:ERROR:bus.cc(393)] Failed to connect to the bus: Address does not contain a colon �[31m+4ms�[0m
�[31;1mcypress:server:server �[0mGot CONNECT request from www.gstatic.com:443 �[31m+234ms�[0m

I meet the same error, is there any update?

@jennifer-shehane
Copy link
Member

This issue will be closed to further comment as the exact issue here was resolved and tested.

If you're experiencing a bug similar to this in Cypress, please open a new issue with a fully reproducible example that we can run. There may be a specific edge case with the issue that we need more detail to fix.

@cypress-io cypress-io locked as resolved and limited conversation to collaborators Jul 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
browser: electron type: regression A bug that didn't appear until a specific Cy version release v3.5.0 🐛 Issue present since 3.5.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants