cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
47.03k stars 3.19k forks source link

When launching cypress in background cy.exec cause chrome to freeze #24255

Open freddidierRTE opened 2 years ago

freddidierRTE commented 2 years ago

Current behavior

On a linux OS using chrome with version cypress version 10.10.0 (pb reproduce with previous versions as well) , node version 14.20.1

Launch cypress in background : ./node_modules/.bin/cypress open &

Execute following test :

describe ('Exec',function () {

  before('Exec', function () {
    cy.exec('ls');
  });

  describe('Basic test', function () {

    it('test ', ()=>{
     cy.visit('');
    })
  })

})

When launching cypress in foreground (./node_modules/.bin/cypress open) it works

Desired behavior

exec works when launching cypress in background

Test code to reproduce

describe ('Exec',function () {

  before('Exec', function () {
    cy.exec('ls');
  });

  describe('Basic test', function () {

    it('test ', ()=>{
     cy.visit('');
    })
  })

})

Cypress Version

10.10.0

Node version

14.20.1

Operating System

Ubuntu 20.04.2 LTS

Debug Logs

GET /__cypress/tests?p=cypress/integration/test.spec.js 200 846.964 ms - -
  cypress:webpack finished bundling /home/didierfre/.config/Cypress/cy/production/projects/cypress-f7df22d4ac11f6bda7529ad77a4b0b51/bundles/cypress/support/e2e.js +426ms
Hash: 59714b33b841c8b9673d
Version: webpack 4.46.0
Time: 1179ms
Built at: 14/10/2022 12:14:04
 Asset     Size  Chunks             Chunk Names
e2e.js  543 KiB    main  [emitted]  main
Entrypoint main = e2e.js
[0] multi ./cypress/support/e2e.js 28 bytes {main} [built]
[./cypress/support/commands.js] 2.04 KiB {main} [built]
[./cypress/support/e2e.js] 747 bytes {main} [built]
[./node_modules/cypress-terminal-report/src/CtrError.js] 132 bytes {main} [built]
[./node_modules/cypress-terminal-report/src/collector/LogCollectBrowserConsole.js] 2.53 KiB {main} [built]
[./node_modules/cypress-terminal-report/src/collector/LogCollectCypressCommand.js] 812 bytes {main} [built]
[./node_modules/cypress-terminal-report/src/collector/LogCollectCypressFetch.js] 2.21 KiB {main} [built]
[./node_modules/cypress-terminal-report/src/collector/LogCollectCypressIntercept.js] 1.26 KiB {main} [built]
[./node_modules/cypress-terminal-report/src/collector/LogCollectCypressLog.js] 403 bytes {main} [built]
[./node_modules/cypress-terminal-report/src/collector/LogCollectCypressRequest.js] 5.54 KiB {main} [built]
[./node_modules/cypress-terminal-report/src/collector/LogCollectCypressRoute.js] 1.41 KiB {main} [built]
[./node_modules/cypress-terminal-report/src/collector/LogCollectCypressXhr.js] 2.7 KiB {main} [built]
[./node_modules/cypress-terminal-report/src/collector/LogCollectExtendedControl.js] 13 KiB {main} [built]
[./node_modules/cypress-terminal-report/src/collector/LogCollectSimpleControl.js] 4.1 KiB {main} [built]
[./node_modules/cypress-terminal-report/src/installLogsCollector.js] 3.71 KiB {main} [built]
    + 55 hidden modules
  cypress:webpack - compile finished for /home/didierfre/projets/opfab/git/operatorfabric-core/src/test/cypress/cypress/support/e2e.js, initial? true +7ms
  cypress:lifecycle:ProjectConfigManager promise resolved for id 'inv8' with value /home/didierfre/.config/Cypress/cy/production/projects/cypress-f7df22d4ac11f6bda7529ad77a4b0b51/bundles/cypress/support/e2e.js +435ms
  cypress:server:controllers:spec sending spec { filePath: '/home/didierfre/.config/Cypress/cy/production/projects/cypress-f7df22d4ac11f6bda7529ad77a4b0b51/bundles/cypress/support/e2e.js' } +435ms
GET /__cypress/tests?p=cypress/support/e2e.js 200 1284.547 ms - -
  cypress:server:socket-base automation:request get:cookies { domain: 'localhost' } +36s
  cypress:server:automation:cookies getting:cookies { domain: 'localhost' } +0ms
  cypress:server:automation:cookies received get:cookies [] +2ms
  cypress:server:socket-base backend:request { eventName: 'reset:server:state', args: [] } +3ms
  cypress:proxy:http:util:buffers resetting buffers +37s
  cypress:server:remote-states resetting remote state +1s
  cypress:server:socket-base backend:request { eventName: 'exec', args: [ { cmd: 'ls', timeout: 60000, env: {} } ] } +11ms

Other

No response

AtofStryker commented 2 years ago

Hi @freddidierRTE . Thank you for opening an issue. I tried giving this a reproduction here on my ubuntu machine but didn't have any luck reproducing it. Would you be able to work with the reproduction to reproduce this issue for us?

freddidierRTE commented 2 years ago

Hi @AtofStryker , i reproduced it with you test code

New element , if i put back in foreground the task in the shell , it stop freezing and execute the test ,debug logs (see the fg shell command in the log )

  cypress:server:controllers:spec sending spec { filePath: '/home/didierfre/.config/Cypress/cy/production/projects/cypress-issue-24255-e09ff01d732e7f6af3fe5463a2257406/bundles/cypress/support/e2e.js' } +
19ms                                                                                                                                                                                                       
GET /__cypress/tests?p=cypress/support/e2e.js 200 975.319 ms - -                                                                                                                                           
  cypress:server:socket-base automation:request get:cookies { domain: 'localhost' } +7s                                                                                                                    
  cypress:server:automation:cookies getting:cookies { domain: 'localhost' } +0ms                                                                                                                           
  cypress:server:automation:cookies received get:cookies [] +2ms                                                                                                                                           
  cypress:server:socket-base backend:request { eventName: 'reset:server:state', args: [] } +23ms                                                                                                           
  cypress:proxy:http:util:buffers resetting buffers +8s                                                                                                                                                    
  cypress:server:remote-states resetting remote state +481ms                                                                                                                                               
  cypress:server:socket-base backend:request { eventName: 'exec', args: [ { cmd: 'ls', timeout: 60000, env: {} } ] } +13ms                                                                                 
fg                                                                                                                                                                                                         
./node_modules/.bin/cypress open                                                                                                                                                                           
  cypress:server:util:socket_allowed allowed socket closed, removing { localPort: 56920 } +9s                                                                                                              
  cypress:server shell /bin/bash profile ~/.bash_profile +0ms                                                                                                                                              
  cypress:server cy.exec found shell /bin/bash +0ms                                                                                                                                                        
  cypress:server and is running command: ls +0ms                                                                                                                                                           
  cypress:server in folder: /home/didierfre/projets/opfab/git/cypress-issue-24255 +0ms                                                                                                                     
  cypress:server:util:process_profiler current & mean memory and CPU usage by process group: 
freddidierRTE commented 2 years ago

I reproduce it as well with the provided electron browser

AtofStryker commented 2 years ago

@freddidierRTE maybe I am missing something. What command in your terminal did you run or did you just one of the provided npm scripts to reproduce?

freddidierRTE commented 2 years ago

Starting from the root of your github repository :

Test 1 : In the shell :

./node_modules/.bin/cypress open

Launch test via UI

image

--> works as intended

Test 2 : In the shell

./node_modules/.bin/cypress open &

Launch test via UI --> It freezes

image

Test 3:

In the shell

./node_modules/.bin/cypress open &

Launch test via UI --> It freezes

In the shell :

fg

--> works as intended

AtofStryker commented 2 years ago

interesting. I gave this a go and wasn't able to get this to freeze but it did crash on me every time I tried to run ./node_modules/.bin/cypress open &

nemonemi commented 1 year ago

I am experiencing this as well with Cypress 12.9.0. I run it with nx e2e project-e2e (https://nx.dev). The weird thing is it just started happening.