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

Cannot read property '__error' of null #7518

Closed
csalazar1 opened this issue May 28, 2020 · 8 comments · Fixed by #7534
Closed

Cannot read property '__error' of null #7518

csalazar1 opened this issue May 28, 2020 · 8 comments · Fixed by #7534
Assignees
Labels
type: regression A bug that didn't appear until a specific Cy version release v4.6.0 🐛 Issue present since 4.6.0

Comments

@csalazar1
Copy link

csalazar1 commented May 28, 2020

As of version 4.6.0, Cypress has been throwing this exception during a very simple test that consists of

  • Routing a request
  • Logging in
  • Visiting a page
  • Make sure an element is displayed

This issue is reproducible with 4.7.0 version as well. It works perfectly fine in version 4.5.0.
Here's how to reproduce

  1. Set baseUrl in cypress.json to: https://qa1-cypress.st.dev
  2. Run the following test using either Cypress version 4.6.0 or later
it('Business Unit Test', () => {
    cy.server()
    cy.route({
      method: 'GET',
      url: '/Settings/GetBusinessUnits*',
      response: [{
        Id: 56345,
        Name: 'Test BU',
        OfficialName: 'Test BU',
        Active: true,
        Logo: null,
        PostDate: null,
        QbExportState: null
      }],
      status: 200
    })
    cy.request('POST', '/Auth/Login', { username: 'cydemoadmin', password: 'Test1@#$%' })
    cy.visit('/#/Settings/business-units')
    cy.get('.e2e-column-name').contains('Test BU').should('be.visible')
  })

Here's a screenshot of the exception stack trace
exceptionStackTrace

@MorganNesbitt
Copy link

Same, tests that never had this now have it appearing all over the place. Cypress says it originates from our app but it doesnt seem like it is, or if it is its not appearing in a console anywhere.

@FLGMwt
Copy link

FLGMwt commented May 28, 2020

Struggled with this as well and the issue seems to with 200 responses with response bodies of the literal value null. Cypress errors handling them and the request in the runner appears to be hung. This does break my tests.

I'll put up a repro in the next hour but for now, the following should be a good workaround:

it('my test', () => {
  cy.on('uncaught:exception', err => {
    return !err.message.includes(`Cannot read property '__error' of null`);
  });
  // my test code ...
});

EDIT: I ruled out the simplest case when I was attempting to repro this. The demo project is here: https://github.com/FLGMwt/cypress-null-response-regression

I'm not yet sure what's different about my application code that returns null and this demo server that returns null, but I do hope this is a start. I'll give a little time to repro-ing tomorrow, but hope this helps

@jdmairs
Copy link

jdmairs commented May 28, 2020

I'm seeing it now too after upgrading to v4.7 from v4.5. This test has never failed before. Interesting how its mixed in with the Code Coverage section.

image

@jennifer-shehane
Copy link
Member

jennifer-shehane commented May 29, 2020

Thanks for providing a reproducible example! I can recreate this and see this was introduced in Cypress 4.6.0. I suspect this is related to our error improvements #3930

I also see these files were converted from coffeescript in the 4.6.0 release in #7227

spec.js

it('Business Unit Test', () => {
  cy.request('POST', 'https://qa1-cypress.st.dev/Auth/Login', { username: 'cydemoadmin', password: 'Test1@#$%' })
  cy.visit('https://qa1-cypress.st.dev/#/Settings/business-units')
  cy.get('.foobar')
})

4.5.0

Screen Shot 2020-05-29 at 4 01 22 PM

4.6.0

Screen Shot 2020-05-29 at 4 02 52 PM

Stack trace

This is throwing from this line of code, where the body is null.

https://github.com/cypress-io/cypress/blob/issue-7428/packages/driver/src/cypress/xml_http_request.js#L97:L97

In the example, there is a request to https://qa1-cypress.st.dev/DataProvider/GetEmbeddedPhoneUserConfiguration that has a null response.body.

TypeError: The following error originated from your application code, not from Cypress.

  > Cannot read property '__error' of null

When Cypress detects uncaught errors originating from your application it will automatically fail the current test.

This behavior is configurable, and you can choose to turn this off by listening to the `uncaught:exception` event.
    at XMLHttpRequest._getFixtureError (https://qa1-cypress.st.dev/__cypress/runner/cypress_runner.js:163144:22)
    at onLoadFn (https://qa1-cypress.st.dev/__cypress/runner/cypress_runner.js:161996:27)
    at XMLHttpRequest.<anonymous> (https://qa1-cypress.st.dev/__cypress/runner/cypress_runner.js:161980:25)
From previous event:
    at run (https://qa1-cypress.st.dev/__cypress/runner/cypress_runner.js:155845:19)
    at Object.cy.<computed> [as request] (https://qa1-cypress.st.dev/__cypress/runner/cypress_runner.js:156289:11)
    at Context.runnable.fn (https://qa1-cypress.st.dev/__cypress/runner/cypress_runner.js:156514:21)
    at callFn (https://qa1-cypress.st.dev/__cypress/runner/cypress_runner.js:95404:21)
    at Test.../driver/node_modules/mocha/lib/runnable.js.Runnable.run (https://qa1-cypress.st.dev/__cypress/runner/cypress_runner.js:95391:7)
    at https://qa1-cypress.st.dev/__cypress/runner/cypress_runner.js:160893:28
From previous event:
    at Object.onRunnableRun (https://qa1-cypress.st.dev/__cypress/runner/cypress_runner.js:160881:20)
    at $Cypress.action (https://qa1-cypress.st.dev/__cypress/runner/cypress_runner.js:152580:61)
    at Test.Runnable.run (https://qa1-cypress.st.dev/__cypress/runner/cypress_runner.js:159483:13)
    at Runner.../driver/node_modules/mocha/lib/runner.js.Runner.runTest (https://qa1-cypress.st.dev/__cypress/runner/cypress_runner.js:96063:10)
    at https://qa1-cypress.st.dev/__cypress/runner/cypress_runner.js:96189:12
    at next (https://qa1-cypress.st.dev/__cypress/runner/cypress_runner.js:95972:14)
    at https://qa1-cypress.st.dev/__cypress/runner/cypress_runner.js:95982:7
    at next (https://qa1-cypress.st.dev/__cypress/runner/cypress_runner.js:95884:14)
    at https://qa1-cypress.st.dev/__cypress/runner/cypress_runner.js:95950:5
    at timeslice (https://qa1-cypress.st.dev/__cypress/runner/cypress_runner.js:89876:27)

@jennifer-shehane jennifer-shehane added v4.6.0 🐛 Issue present since 4.6.0 type: regression A bug that didn't appear until a specific Cy version release labels May 29, 2020
@cypress-bot cypress-bot bot added the stage: needs investigating Someone from Cypress needs to look at this label May 29, 2020
@chrisbreiding chrisbreiding self-assigned this May 29, 2020
@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review stage: work in progress and removed stage: needs investigating Someone from Cypress needs to look at this stage: needs review The PR code is done & tested, needs review labels May 29, 2020
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jun 1, 2020

The code for this is done in cypress-io/cypress#7534, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@ahmedkotb
Copy link

@jennifer-shehane is this going to be released as a hotfix (in a day or two) ? or will it be released according to the normal release schedule (every two weeks if i remember correctly) ?

@jennifer-shehane
Copy link
Member

jennifer-shehane commented Jun 2, 2020

This will be released in our normal release schedule next Monday. You can downgrade to Cypress 4.5.0 in the meantime so it's not blocking.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jun 8, 2020

Released in 4.8.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v4.8.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Jun 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: regression A bug that didn't appear until a specific Cy version release v4.6.0 🐛 Issue present since 4.6.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants