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

Crash when plugins event handler is undefined #4261

Open
bahmutov opened this issue May 20, 2019 · 0 comments

Comments

2 participants
@bahmutov
Copy link
Collaborator

commented May 20, 2019

Bug

Crashes in 3.2.0 and 3.3.0, have not tried earlier versions
Mac

Reproduction in https://github.com/cypress-io/cypress-test-tiny/tree/no-plugins-export

npm install
npm run cypress:open

and click on spec file

Reproduction

Register undefined event handler in plugins.js file for an event like

module.exports = (on, config) => {
  // `on` is used to hook into various events Cypress emits
  // `config` is the resolved Cypress config
  on('file:preprocessor')
}

and get the following crash

Screen Shot 2019-05-20 at 3 23 40 PM

Stack trace in the terminal

GET /__cypress/tests?p=cypress/support/index.js-383 200 8.371 ms - 146
TypeError: event.handler is not a function
    at invoke (/Users/gleb/Library/Caches/Cypress/3.3.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:17:16)
    at /Users/gleb/Library/Caches/Cypress/3.3.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:48:16
    at tryCatcher (/Users/gleb/Library/Caches/Cypress/3.3.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
    at Function.Promise.attempt.Promise.try (/Users/gleb/Library/Caches/Cypress/3.3.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/method.js:39:29)
    at Object.wrapChildPromise (/Users/gleb/Library/Caches/Cypress/3.3.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:47:28)
    at Object.wrap (/Users/gleb/Library/Caches/Cypress/3.3.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/preprocessor.js:25:8)
    at execute (/Users/gleb/Library/Caches/Cypress/3.3.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:80:20)
    at EventEmitter.ipc.on (/Users/gleb/Library/Caches/Cypress/3.3.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:136:5)
    at emitThree (events.js:136:13)
    at EventEmitter.emit (events.js:217:7)
    at process.<anonymous> (/Users/gleb/Library/Caches/Cypress/3.3.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:25:29)
    at emitTwo (events.js:126:13)
    at process.emit (events.js:214:7)
    at emit (internal/child_process.js:772:12)
    at _combinedTickCallback (internal/process/next_tick.js:141:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
GET /__cypress/tests?p=cypress/integration/spec.js-143 200 8.418 ms - 146

It would be nicer to have a much better error message here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.