Cypress: Application exceptions not firing uncaught:exception binding

Created on 30 Jan 2019  路  6Comments  路  Source: cypress-io/cypress

Current behavior:

Some uncaught exceptions thrown from my application do not fire the uncaught:exception event. It looks like this is happening when the application throws exceptions in callbacks from XHR requests (we're using Backbone.js to make these requests).

It looks like Cypress thinks these exceptions originate from my test code. For application exceptions there should be a small blurb about how to ignore application exceptions.

Error in command log:
image

Stacktrace:

TypeError: Cannot read property 'message' of undefined
    at child.key (https://application.com/assets/ApplicationCode.min-4c6807786eed7be0bfd0d805e02a6535.js:1:222263)
    at child.n (https://application.com/assets/ApplicationCode.min-4c6807786eed7be0bfd0d805e02a6535.js:1:2913565)
    at Object.<anonymous> (https://application.com/assets/ApplicationCode.min-4c6807786eed7be0bfd0d805e02a6535.js:1:2914235)
    at Object.error (https://application.com/assets/ApplicationLibs.min-79f82dc057c8850526880d9c9ac5487b.js:43563:19)
    at fire (https://application.com/assets/ApplicationLibs.min-79f82dc057c8850526880d9c9ac5487b.js:3836:31)
    at Object.fireWith [as rejectWith] (https://application.com/assets/ApplicationLibs.min-79f82dc057c8850526880d9c9ac5487b.js:3966:7)
    at done (https://application.com/assets/ApplicationLibs.min-79f82dc057c8850526880d9c9ac5487b.js:9775:14)
    at XMLHttpRequest.<anonymous> (https://application.com/assets/ApplicationLibs.min-79f82dc057c8850526880d9c9ac5487b.js:10015:9)
From previous event:
    at run (https://application.com/__cypress/runner/cypress_runner.js:63889:15)
    at Object.cy.(anonymous function) [as visit] (https://application.com/__cypress/runner/cypress_runner.js:64115:11)
    at Context.runnable.fn (https://application.com/__cypress/runner/cypress_runner.js:64253:20)
    at callFn (https://application.com/__cypress/runner/cypress_runner.js:33209:21)
    at Test.Runnable.run (https://application.com/__cypress/runner/cypress_runner.js:33202:7)
    at https://application.com/__cypress/runner/cypress_runner.js:67163:28
    at <anonymous>
From previous event:
    at Object.onRunnableRun (https://application.com/__cypress/runner/cypress_runner.js:67158:20)
    at $Cypress.action (https://application.com/__cypress/runner/cypress_runner.js:62533:51)
    at Test.Runnable.run (https://application.com/__cypress/runner/cypress_runner.js:66229:20)
    at Runner.runTest (https://application.com/__cypress/runner/cypress_runner.js:33672:10)
    at https://application.com/__cypress/runner/cypress_runner.js:33778:12
    at next (https://application.com/__cypress/runner/cypress_runner.js:33592:14)
    at https://application.com/__cypress/runner/cypress_runner.js:33602:7
    at next (https://application.com/__cypress/runner/cypress_runner.js:33534:14)
    at https://application.com/__cypress/runner/cypress_runner.js:33570:5
    at timeslice (https://application.com/__cypress/runner/cypress_runner.js:28811:27)

Desired behavior:

These exceptions should be fire the uncaught:exception binding so I can ignore them and move on.

Steps to reproduce: (app code and test code)

In progress.

Versions

Observable on all combinations of
Cypress 3.1.0
Windows 10
Chrome 72, Canary 74, Electron 59

ready for work unhandled exceptions 鈿狅笍

Most helpful comment

Hi @jennifer-shehane, would you be able to provide any timeline around this issue? We would greatly appreciate it. Thanks.

All 6 comments

Can you provide an example of test code + application code that produces this error? We'll need to reproduce this locally to look into it.

Wanted to provide an update, I will try to get an example this week.

Hi @jennifer-shehane

I've created an example which reproduces this issue. The example application throws an initial exception which is caught by Cypress, then throws a second exception in a callback which is uncaught.

https://github.com/hinfaits/cypress-3256

Cheers,
Aaron

Can confirm, the repo reproduces the issue.

In 4.0, we've fixed some unhandled exception errors, but it looks like trying this test in that branch does not change the behavior.

Hi @jennifer-shehane, would you be able to provide any timeline around this issue? We would greatly appreciate it. Thanks.

Hi @jennifer-shehane,

I would like to tackle this, but I need some direction from you or the team. I've setup my environment and have a rough understanding of the code execution, but I'm not sure what's the correct fix for this bug.

In the driver package, I can see the error being thrown is caught in server.coffee which then calls the onError method in xhr.coffee which eventually stops the test. I can naively fix my issue by removing if r = state("reject") ... r(err) but I'm sure that has negative consequences.

It would be great if someone could help me out.

Thanks

Was this page helpful?
0 / 5 - 0 ratings