Skip to content

Cypress crashes completely on some network requests #5585

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

Closed
vitalybe opened this issue Nov 2, 2019 · 5 comments · Fixed by #5605
Closed

Cypress crashes completely on some network requests #5585

vitalybe opened this issue Nov 2, 2019 · 5 comments · Fixed by #5605
Assignees

Comments

@vitalybe
Copy link

vitalybe commented Nov 2, 2019

Current behavior:

Cypress crashes completely (the browser and the application) with the following stack after I navigate to a page that does multiple AJAX requests:

TypeError: Cannot read property 'length' of null
    at Writable.onWrite [as _write] (/Users/vitalyb/Library/Caches/Cypress/3.6.0/Cypress.app/Contents/Resources/app/packages/server/lib/util/stream_buffer.js:13:46)
    at doWrite (_stream_writable.js:415:12)
    at writeOrBuffer (_stream_writable.js:399:5)
    at Writable.write (_stream_writable.js:299:11)
    at Duplexify._write (/Users/vitalyb/Library/Caches/Cypress/3.6.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/duplexify/index.js:212:22)
    at doWrite (/Users/vitalyb/Library/Caches/Cypress/3.6.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/duplexify/node_modules/readable-stream/lib/_stream_writable.js:405:139)
    at writeOrBuffer (/Users/vitalyb/Library/Caches/Cypress/3.6.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/duplexify/node_modules/readable-stream/lib/_stream_writable.js:394:5)
    at Duplexify.Writable.write (/Users/vitalyb/Library/Caches/Cypress/3.6.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/duplexify/node_modules/readable-stream/lib/_stream_writable.js:303:11)
    at IncomingMessage.ondata (_stream_readable.js:706:22)
    at IncomingMessage.emit (events.js:199:15)
    at IncomingMessage.Readable.read (_stream_readable.js:497:10)
    at flow (_stream_readable.js:970:34)
    at Request.pipeOnDrainFunctionResult (_stream_readable.js:774:7)
    at Request.emit (events.js:194:13)
    at ClientRequest.<anonymous> (/Users/vitalyb/Library/Caches/Cypress/3.6.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/request/request.js:778:10)
    at ClientRequest.emit (events.js:194:13)
    at TLSSocket.ondrain (internal/http.js:31:44)
    at TLSSocket.emit (events.js:194:13)
    at onwriteDrain (_stream_writable.js:495:12)
    at afterWrite (_stream_writable.js:483:5)
    at onwrite (_stream_writable.js:476:7)
    at WriteWrap.onWriteComplete [as oncomplete] (internal/stream_base_commons.js:91:10)

TypeError: Cannot read property 'length' of null
    at Writable.onWrite [as _write] (/Users/vitalyb/Library/Caches/Cypress/3.6.0/Cypress.app/Contents/Resources/app/packages/server/lib/util/stream_buffer.js:13:46)
    at doWrite (_stream_writable.js:415:12)
    at writeOrBuffer (_stream_writable.js:399:5)
    at Writable.write (_stream_writable.js:299:11)
    at Duplexify._write (/Users/vitalyb/Library/Caches/Cypress/3.6.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/duplexify/index.js:212:22)
    at doWrite (/Users/vitalyb/Library/Caches/Cypress/3.6.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/duplexify/node_modules/readable-stream/lib/_stream_writable.js:405:139)
    at writeOrBuffer (/Users/vitalyb/Library/Caches/Cypress/3.6.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/duplexify/node_modules/readable-stream/lib/_stream_writable.js:394:5)
    at Duplexify.Writable.write (/Users/vitalyb/Library/Caches/Cypress/3.6.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/duplexify/node_modules/readable-stream/lib/_stream_writable.js:303:11)
    at IncomingMessage.ondata (_stream_readable.js:706:22)
    at IncomingMessage.emit (events.js:199:15)
    at IncomingMessage.Readable.read (_stream_readable.js:497:10)
    at flow (_stream_readable.js:970:34)
    at Request.pipeOnDrainFunctionResult (_stream_readable.js:774:7)
    at Request.emit (events.js:194:13)
    at ClientRequest.<anonymous> (/Users/vitalyb/Library/Caches/Cypress/3.6.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/request/request.js:778:10)
    at ClientRequest.emit (events.js:194:13)
    at TLSSocket.ondrain (internal/http.js:31:44)
    at TLSSocket.emit (events.js:194:13)
    at onwriteDrain (_stream_writable.js:495:12)
    at afterWrite (_stream_writable.js:483:5)
    at onwrite (_stream_writable.js:476:7)
    at WriteWrap.onWriteComplete [as oncomplete] (internal/stream_base_commons.js:91:10)```

Desired behavior:

I'd like it not to crash.

Steps to reproduce: (app code and test code)

I'm performing the test on an internal site, so I can't really reproduce it.

Versions

cypress@3.6.0
MacOS, High Sierra, 10.13.6 (17G7024)

@vitalybe
Copy link
Author

vitalybe commented Nov 2, 2019

Adding here: https://github.com/cypress-io/cypress/blob/develop/packages/server/lib/util/stream_buffer.js#L13

The following fixes that:

    if(!chunk || !buffer) {
      return;
    }

@brian-mann
Copy link
Member

This is likely due to the XHR mocking changes in 3.6.0 - I can think of a few situations where if requests are leaking from one test into another - they could possibly cause this.

If then a request goes out and signals it should be stubbed - but the state doesn't have a record for it, the request will fail, the socket will be closed, but I believe it'll still have a buffer that needs draining, and because we null out the internal request it'll end up being null - which leads to this failure.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Nov 7, 2019

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

@cypress-bot cypress-bot bot removed the stage: needs review The PR code is done & tested, needs review label Nov 7, 2019
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Nov 7, 2019

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

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Nov 8, 2019

Released in 3.6.1.

@cypress-io cypress-io locked as resolved and limited conversation to collaborators Jan 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants