Detect and Recover when Browser Hangs/Crashes/Dies
See original GitHub issueCurrent behavior
Cypress does not handle browser tab crashes, hanging browsers or issues related to browsers unexpectedly dying. This cause Cypress to hang indefinitely until the process is manually stopped or CI times out.
Desired behavior
Cypress should handle tab crashes and timeout on browsers hangs.
-
Tab Crash - Cypress should handle closing the tab, reopening a new tab and continue the test execution.
-
Browser hangs - The Cypress runner should timeout the test, send the status to the server to end the test, report the failure to the dashboard (if recording enabled) before killing the current browser instance and launching a new instance to continue test execution.
The quick-(er) fix will be to fail the current test and pickup the next test to provide reporting on the tests that were able to run. The ideal solution would be re-attempting the test that experienced the crash to reduce test flake & CI costs for users and/or to help identify memory issues within the code under test.
Considerations to Keep in Mind
When the browser tab and/or instance is killed and re-launched, ensure we are release the node resources initially used to ensure JS memory does not grow with each launch.
It would be great if there was a way to capture the crash reason to provide users with better info (i.e. need to increase the memory with shm_size
– suggested as solution for #6695)
Test code to reproduce (chrome)
Can manually reproduce in Chrome in https://github.com/cypress-io/cypress-test-tiny/tree/issue-22506
- run
npm run cypress:run-hang
(enables browser debug logs with headed chrome) - first spec runs, when
cy.pause()
starts, enterchrome://crash
orchrome://hang
in the URL to view behavior.
If running DEBUG=cypress* npm run cypress:run --browser chrome --headed
you can see the full log output and the process_profiling logging continuously as Cypress hangs.
Cypress Version
Happening since v4.2. Current Version 10.3.0
Existing Issues Around This Behavior:
Issues to Do This Work:
- Detect Browser Launching Crashes: #1022
- Detect Browser Crashes: #6170 (all browsers), #1660 (electron)
- Recover from Browser Crash: #349
Bug Reports:
Issue Analytics
- State:
- Created a year ago
- Reactions:22
- Comments:5 (1 by maintainers)
Top GitHub Comments
@jennifer-shehane Hi Jennifer, can you please tell us if and when the problem will be fixed?
Hi @emilyrohrbough, thank you so much for checking out this issue! It has been with us for months and is very frustrating.
What I don’t understand is that it works locally on my laptop with
npx cypress run
, but as soon as cypress runs via docker image in a pipeline, it comes to these crashes. Can you please explain this to me?