question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cypress Crash: Uncaught TypeError: Cannot read properties of undefined (reading 'emit')

See original GitHub issue

Current behavior

Upon finishing running my Cypress script, Cypress would crash (On Chrome Latest)

In dev tools we can see the following error:

cypress_runner.js:191727 Uncaught TypeError: Cannot read properties of undefined (reading 'emit')
    at Socket.<anonymous> (cypress_runner.js:191727)
    at Socket.../../node_modules/component-emitter/index.js.Emitter.emit (cypress_runner.js:18455)
    at Socket.emit (cypress_runner.js:199652)
    at Socket.emitEvent (cypress_runner.js:199401)
    at Socket.onevent (cypress_runner.js:199388)
    at Socket.onpacket (cypress_runner.js:199352)
    at Manager.../../node_modules/component-emitter/index.js.Emitter.emit (cypress_runner.js:18455)
    at Manager.emitReserved (cypress_runner.js:199665)
    at Manager.ondecoded (cypress_runner.js:198944)
    at Decoder.../../node_modules/component-emitter/index.js.Emitter.emit (cypress_runner.js:18455)
    at Decoder.add (cypress_runner.js:199978)
    at Manager.ondata (cypress_runner.js:198936)
    at Socket.../../node_modules/component-emitter/index.js.Emitter.emit (cypress_runner.js:18455)
    at Socket.onPacket (cypress_runner.js:196867)
    at WS.<anonymous> (cypress_runner.js:196676)
    at WS.../../node_modules/component-emitter/index.js.Emitter.emit (cypress_runner.js:18455)

Clicking on the .js line:
 lodash__WEBPACK_IMPORTED_MODULE_0___default.a.each(socketToDriverEvents, event => {
      ws.on(event, (...args) => {
        Cypress.emit(event, ...args);
      });
    });

Desired behavior

No response

Test code to reproduce

Issue seems to happen on screen redirection, not sure if its due to when a session becomes invalid. If anyone can explain what the above is related to I can investigate more before providing sample code.

Cypress Version

9.1.1

Other

No response

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:25
  • Comments:33 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
hereiscasiocommented, Mar 26, 2022

I can confirm this issue existed. On my side, this is all about Cypress Component Testing.

And I think I found some clues of the bug. This bug will only happen if you install any Cypress version large than v.8.1.0 (i.e. v.8.1.0 is safe)

The issue is reproducible, and it’s easy to do:

  1. Clone: https://github.com/cypress-io/cypress-component-testing-examples/tree/main/create-nuxt-app
  2. update Cypress package to 8.2.0
  3. run npx cypress open-ct
  4. you can see the browser console show the error(see attachment)
  5. but if you update Cypress to 8.1.0, no error anymore!!!

image

cc @bahmutov

Thx for reading. And hope this bug can be fixed.

2reactions
DobQAcommented, May 4, 2022

Issues still exists in Cypress 9.6, Im hoping fix comes in Cypress 10, how can we get a Cypress dev on this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cypress TypeError: Cannot read properties of undefined ...
js`, but it threw an error. TypeError: Cannot read properties of undefined (reading 'uid') at Object. statSync (C:\Windows\SysWOW64\config\ ...
Read more >
Error Messages | Cypress Documentation
We found an error preparing your test file. This message means that Cypress encountered an error when compiling and/or bundling your test file....
Read more >
history.js:47 uncaught typeerror: cannot read properties of ...
The solution to TypeError: Cannot read properties of undefined Always conditionally check for the variable that is undefined before accessing the value. The ......
Read more >
cypress-io/cypress - Gitter
Uncaught DOMException: Failed to read the 'contentDocument' property from ... /57358163/typeerror-cannot-read-property-click-of-undefined-cypress/57370009.
Read more >
TypeError: Cannot read property '$emit' of undefined - Laracasts
I want to call to a method in my parent component within my child component. so I used an event for that. but...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found