cypress: 3.1.1 regression: cookie can't be set when visiting local devserver
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:
- Add Cypress to a project or create a Cypress project
- Just add a single file with the test case above
- 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
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 2
- Comments: 23 (7 by maintainers)
Commits related to this issue
- fix #2724 do not set url on unparseable cookies — committed to cypress-io/cypress by brian-mann 6 years ago
- do not set url on invalid cookies (#2788) fixes #2724 — committed to cypress-io/cypress by brian-mann 6 years ago
Released in
3.1.2.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)
We are also seeing the same issue on our builds. Locking to 3.1.0 fixed it.
@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 bothcy.visit()andcy.request()failed.Under the hood nothing special is happening. It just goes to our login page without any redirects.
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.setCookieor based on the way your webserver is sendingSet-Cookieheaders 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.setCookiein your test code?It looks like its failing in both:
cy.visit()andcy.request()Could perhaps one of you post what you do under the hood via that visit or request? This may involve multiple server redirects.