cypress-io / cypress

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

Fix race condition when `before:spec` plugin event throws an exception #24102

Open ryanthemanuel opened 2 years ago

ryanthemanuel commented 2 years ago

What would you like?

I would like to ensure that tests immediately stop execution when the before:spec plugin hook throws an exception.

Why is this needed?

This will ensure that the stack trace in this scenario is as clean as possible. Currently, we will occasionally see this tacked on the end of the stack trace:

ERR_FAILED (-2) loading 'http://localhost:45831/__/#/specs/runner?file=cypress/e2e/run_event_throws.cy.js'
Error: ERR_FAILED (-2) loading 'http://localhost:45831/__/#/specs/runner?file=cypress/e2e/run_event_throws.cy.js'
    at rejectAndCleanup (node:electron/js2c/browser_init:165:7501)
    at EventEmitter.stopLoadingListener (node:electron/js2c/browser_init:165:7876)
    at EventEmitter.emit (node:events:527:29)

Additional information

In 9.0 of Cypress we would execute this hook as a part of the runSpec method so it was easy to fail when things went wrong. Now we execute this hook as a response to a websocket events which makes halting the whole test execution at that moment pretty difficult with how things are currently structured

github-actions[bot] commented 1 year ago

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

github-actions[bot] commented 1 year ago

This issue has been closed due to inactivity.