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

3.1.1 regression: cookie can't be set when visiting local devserver #2724

Closed
KoenCa opened this issue Nov 6, 2018 · 23 comments · Fixed by #2788
Closed

3.1.1 regression: cookie can't be set when visiting local devserver #2724

KoenCa opened this issue Nov 6, 2018 · 23 comments · Fixed by #2788
Assignees
Labels
type: regression A bug that didn't appear until a specific Cy version release
Milestone

Comments

@KoenCa
Copy link

KoenCa commented Nov 6, 2018

I was just following the tutorial and trying to setup simple tests for our app and an error stopped me.

Current behavior:

The very simple test case:

describe("Login", function() {
  it("Goes to login page", function() {
    cy.visit("https://localhost:8443");
  });
});

Generates the following error in the test runner:

CypressError: cy.visit() failed trying to load:

https://localhost:8443/

We attempted to make an http request to this URL but the request failed without a response.

We received this error at the network level:

  > TypeError: Cannot set property 'url' of undefined

Common situations why this would fail:
  - you don't have internet access
  - you forgot to run / boot your web server
  - your web server isn't accessible
  - you have weird network configuration settings on your computer

The stack trace for this error is:

TypeError: Cannot set property 'url' of undefined
    at Object.setCookie (/Users/koen/Library/Caches/Cypress/3.1.1/Cypress.app/Contents/Resources/app/packages/server/lib/request.js:91:20)
    at addCookie

Desired behavior:

I want Cypress to open my page so I can start writing tests 😄

Steps to reproduce:

  1. Add Cypress to a project or create a Cypress project
  2. Just add a single file with the test case above
  3. Run the test runner with that test.

Reproduce is probably going to be hard, because visiting a production version of our app with Cypress worked correctly.

Versions

  • Cypress: 3.1.1
  • Chrome: 70
  • OS: macOS High Sierra

Workaround

I first asked a question about this on the Gitter channel and downgrading to 3.1.0 made the test case above work and my page was loaded correctly.

Extra

I think something goes wrong here: request.coffee

@jennifer-shehane
Copy link
Member

Hey @KoenCa, we'll need a reproducible example. Following your steps to reproduce will not reproduce the problem without having you app locally running - which you did not provide.

@jennifer-shehane jennifer-shehane added the stage: needs information Not enough info to reproduce the issue label Nov 6, 2018
@mcarlotta
Copy link

mcarlotta commented Nov 6, 2018

Experiencing exact same issue now. Our builds are failing. Has been working fine for months.

    CypressError: cy.request() failed trying to load:

    http://localhost:3004/login

    We attempted to make an http request to this URL but the request failed without a response.

    We received this error at the network level:

      > TypeError: Cannot set property 'url' of undefined

    -----------------------------------------------------------

    The request we sent was:

    Method: POST
    URL: http://localhost:3004/login

    -----------------------------------------------------------

    Common situations why this would fail:
      - you don't have internet access
      - you forgot to run / boot your web server
      - your web server isn't accessible
      - you have weird network configuration settings on your computer

    The stack trace for this error is:

    RequestError: TypeError: Cannot set property 'url' of undefined
    at new RequestError 
  
  
 (/Users/mikecarlotta/Library/Caches/Cypress/3.1.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/request-promise-core/lib/errors.js:14:15)
    at Request.plumbing.callback 
  
  (/Users/mikecarlotta/Library/Caches/Cypress/3.1.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/request-promise-core/lib/plumbing.js:87:29)
    at Request.RP$callback [as _callback] 
  
  (/Users/mikecarlotta/Library/Caches/Cypress/3.1.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/request-promise-core/lib/plumbing.js:46:31)
    at self.callback (/Users/mikecarlotta/Library/Caches/Cypress/3.1.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/request/request.js:185:22)
    at emitOne (events.js:115:13)
    at Request.emit (events.js:210:7)
    at addCookie (/Users/mikecarlotta/Library/Caches/Cypress/3.1.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/request/request.js:974:12)
    at Array.forEach (<anonymous>:null:null)
    at Request.onRequestResponse (/Users/mikecarlotta/Library/Caches/Cypress/3.1.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/request/request.js:983:36)
    at emitOne (events.js:115:13)
    at ClientRequest.emit (events.js:210:7)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:565:21)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:116:23)
    at Socket.socketOnData (_http_client.js:454:20)
    at emitOne (events.js:115:13)
    at Socket.emit (events.js:210:7)
    at addChunk (_stream_readable.js:252:12)
    at readableAddChunk (_stream_readable.js:239:11)
    at Socket.Readable.push (_stream_readable.js:197:10)
    at TCP.onread (net.js:589:20)`


    Cypress Console Logs:
    GET /__/ 200 27.390 ms - -
    GET /__cypress/runner/cypress_runner.css 200 47.486 ms - -
    GET /__cypress/runner/cypress_runner.js 200 412.616 ms - -
    GET /__cypress/runner/fonts/fontawesome-webfont.woff2?v=4.6.3 200 2.406 ms - 71896
    GET /__cypress/iframes/__all 200 16.284 ms - -
    GET /__cypress/tests?p=cypress/integration/ci/login.js-084 200 1930.238 ms - -
    GET /__cypress/tests?p=cypress/integration/ci/createProduct.js-690 200 1942.821 ms - -
    GET /__cypress/tests?p=cypress/integration/ci/createVendor.js-564 200 1941.408 ms - -
    GET /__cypress/tests?p=cypress/integration/ci/createTemplate.js-497 200 1943.557 ms - -
    GET /__cypress/tests?p=cypress/integration/ci/importDataUsingWizard.js-996 200 1940.404 ms - -
    (node:28756) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added. Use emitter.setMaxListeners() to increase limit
    GET /__cypress/tests?p=cypress/integration/ci/logout.js-808 200 333.484 ms - -
    GET /__cypress/tests?p=cypress/support/index.js-006 200 2899.710 ms - -
    GET /__cypress/tests?p=cypress/integration/ci/workflows.js-205 200 583.818 ms - -
    GET /__cypress/tests?p=cypress/integration/ci/navigation.js-762 200 589.234 ms - -
    GET /__cypress/tests?p=cypress/integration/local/downloadTemplate.js-930 200 530.182 ms - -
    GET /__cypress/tests?p=cypress/integration/local/downloadCSV.js-763 200 534.804 ms - -
    GET /__cypress/tests?p=cypress/integration/regression/smokeTest.js-342 200 330.775 ms - -
    HEAD / 500 59.337 ms - -
    HEAD / 500 65.618 ms - -
    HEAD / 500 62.465 ms - -
    The automation client disconnected. Cannot continue running tests.
    GET /__/ 200 7.171 ms - -
    GET /__cypress/runner/cypress_runner.css 200 53.499 ms - -
    GET /__cypress/runner/cypress_runner.js 200 421.614 ms - -
    GET /__cypress/runner/fonts/fontawesome-webfont.woff2?v=4.6.3 200 2.659 ms - 71896
    GET /__cypress/iframes/integration/ci/navigation.js 200 7.603 ms - 729
    GET /__cypress/tests?p=cypress/integration/ci/navigation.js-598 200 12.741 ms - -
    GET /__cypress/tests?p=cypress/support/index.js-664 200 33.334 ms - -
    HEAD / 500 76.208 ms - -
    HEAD / 500 69.671 ms - -
    HEAD / 500 73.126 ms - -

@mcarlotta
Copy link

mcarlotta commented Nov 6, 2018

Downgrading Cypress back to 3.1.0 fixed our issue as well

@brian-mann
Copy link
Member

This is definitely a regression in 3.1.1 and somehow made it through thousands of tests without surfacing.

I can see where the problem is occurring but it's not obvious why this is occurring. This is likely due to the way you are either setting cookies via cy.setCookie or based on the way your webserver is sending Set-Cookie headers in responses.

@mcarlotta or @KoenCa Do you happen to know if there's an external site that you can visit that causes this problem? Are either of you two using cy.setCookie in your test code?

It looks like its failing in both: cy.visit() and cy.request()

Could perhaps one of you post what you do under the hood via that visit or request? This may involve multiple server redirects.

@brian-mann brian-mann self-assigned this Nov 6, 2018
@KoenCa
Copy link
Author

KoenCa commented Nov 7, 2018

@brian-mann I don't know an external site that causes the problem. Production instances of our app work while the local version doesn't and there aren't any differences in what is send back by the webserver. I'm not using cy.setCookie, the code that I provided was the only test code I have which made it fail. I can confirm that both cy.visit() and cy.request() failed.

Under the hood nothing special is happening. It just goes to our login page without any redirects.

@agcooke
Copy link

agcooke commented Nov 7, 2018

We are also seeing the same issue on our builds. Locking to 3.1.0 fixed it.

@federicomaffei
Copy link

Our team had the same issue when calling setCookie since the release of 3.1.1. A few notes in the hope it can help with troubleshooting:

  • running Cypress against a locally running version of the system under test works
  • running Cypress from a Docker container against the system under test running on another Docker container fails with the message > TypeError: Cannot set property 'url' of undefined.
  • running Cypress from a Docker container against a production deployed version of the system under test fails with the message > TypeError: Cannot set property 'url' of undefined.

Can confirm that downgrading to 3.1.0 eliminates the behaviour.
Thanks for the good work on Cypress.

@rshafakian
Copy link

We were having this same issue while running 3.1.1. Then I came across something that I'm wondering if you guys are as well. My build site is through Jenkins and when the url is something like my_test_branch.mysite.com it fails, but if my url is mytestbranch.mysite.com then it passes. Can anyone else confirm?

@mcarlotta
Copy link

mcarlotta commented Nov 13, 2018

@rshafakian we have a similar setup to the one you mentioned except ours is structured as ‘app-test.domain.com’ and built using Jenkins. However, even our local and CI tests started failing after update before getting to Jenkins process

@rshafakian
Copy link

@mcarlotta yes our local is running 3.1.0 so that passes. build branch is using 3.1.1, but rolled back to 3.1.0 so it passes. but when our build branch has a url without any dashes or underscores it still passes on 3.1.1 (e.g. 'test.domain.com` instead of 'app-test.domain.com'). Not sure if this is the case for everyone else as well. can you setup your url that way to see if it still fails? might just get closer to solving the problem if that's the case.

@brian-mann
Copy link
Member

I believe this is happening when a server sends back invalid cookies, but I'm working on trying to reproduce it first. I understand how this is happening and should be relatively simple to fix.

@jennifer-shehane
Copy link
Member

The code for this is done, but this has yet to be released. We'll update this issue and reference the changelog when it's released.

@jennifer-shehane jennifer-shehane added stage: pending release and removed stage: needs information Not enough info to reproduce the issue labels Nov 15, 2018
@brian-mann
Copy link
Member

Released in 3.1.2.

@brandonb927
Copy link

Can confirm this is fixed in 3.1.2 in our builds 🎉 Thanks @brian-mann @jennifer-shehane!

@mcarlotta
Copy link

Same for us as well. Thanks!

@jeff-h
Copy link

jeff-h commented Nov 21, 2018

Unfortunately both 3.1.1 and 3.1.2 break my tests (which work fine under 3.1.0).

The initial issue description describes the following error:
TypeError: Cannot set property 'url' of undefined at Object.setCookie

The other error in this thread is:
RequestError: TypeError: Cannot set property 'url' of undefined at new RequestError

I'm getting this latter one, so I'm unsure whether it's due to cookies or not.

I'm testing Drupal 7 which supplies a session cookie like the following:

SSESSc6eea7caf5ccca2bfa189816e5172697=Qd3UYdcybAYUkqyDWNzEk0NWbEa5A83K7mbhMA00wL4; expires=Fri, 14-Dec-2018 04:30:18 GMT; Max-Age=2000000; path=/; domain=.myserver.local; secure; HttpOnly

Perhaps that's invalid (I don't know how to tell). It does work though; in 3.1.0 it's enough to allow Cypress to "log in" to my app.

In 3.1.1 I got the same error as above (RequestError: TypeError: Cannot set property 'url' of undefined at new RequestError). In 3.1.2 I no longer get any error from Cypress, but my tests don't log in, and the session cookie is not saved.

I also tried telling Drupal to remove HttpOnly, thinking that it might be causing an issue with Javascript accessing the cookie, but just get the same result.

@KoenCa
Copy link
Author

KoenCa commented Nov 23, 2018

Can also confirm that 3.1.2 fixed the issue for me! Thanks a lot!

@twslade
Copy link

twslade commented Nov 29, 2018

Fixed for us as well!

@jennifer-shehane jennifer-shehane added the type: regression A bug that didn't appear until a specific Cy version release label Dec 3, 2018
@jm2242
Copy link

jm2242 commented Dec 5, 2018

Still looks like we're getting the same error with 3.1.3:
{ [Error: Failed to parse or set cookie named "current_version".] name: undefined }

Looks like we can workaround this by not setting a cookie on development mode (this seems to be on us for setting a cookie incorrectly)

@jennifer-shehane
Copy link
Member

Hey @jm2242 could you open a new issue detailing your test code and how you are setting cookies. A reproducible example would be best.

@jm2242
Copy link

jm2242 commented Dec 11, 2018

Okay will open a new issue with details from #1321

@jeff-h
Copy link

jeff-h commented Dec 14, 2018

Unfortunately v3.1.3 does not fix the issue I described in #2724 (comment) for me. I'm stuck on 3.1.0, as no subsequent versions manage to log into my Drupal instance.

@jennifer-shehane
Copy link
Member

Hi @jeff-h, could you open a new issue? Since several users have confirmed their issue was resolved with the 3.1.2 release - we will be considering any issues persisting through 3.1.2 as separate issues (or edge cases of this issue) that we'd like to address directly.

We will be closing this issue to further discussion as this specific use case is seen as resolved. Please open a new issue if you are experiencing similar behavior.

@cypress-io cypress-io locked as resolved and limited conversation to collaborators Dec 28, 2018
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.