-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
cy.visit does not send headers / change HTTP method when baseUrl contains :80
#5367
Comments
Ok, something odd is going on here.
BUT, I can get I'm not sure how to explain that behaviour?! |
Further info: There is definitely some Cypress-level caching going on which I've just noticed. The first time I run the tests (with The first request/response is seemingly ignored (even though this request is exactly what I want!), and only the 2nd request/response is provided to the test runner. Afterwards, clicking the re-run tests button results in only 1 request being made to my server (The one without the correct method/headers). It almost feels like a CORS issue (two requests made, but in a CORS situation the first request is usually an OPTIONS req)... ? |
So, it seems the cookie header persists between the two requests (as long as the cookie is set via |
Yes, I can shed some more light on this:
So, although you don't see the correct method and headers in DevTools, they are actually being sent in (2). Only one request is sent to the origin server in a cy.visit. Are you 100% sure that your destination server isn't receiving a it("", () => {
cy.visit({
method: 'POST',
url: 'http://requestbin.net/r/165n5db1'
})
}) Request received: |
@flotwig Thank you for the reply. Yes, my server does get a POST - But only the first time I start the test runner. The response my server gives to the initial POST seems to be ignored as cypress makes a 2nd GET to the server immediately afterwards. When the tests are re-run (i.e I don't close/re-open the test runner) the server only receives a GET. Edit: Just re-read your comment. I don't think (5) happens as you described... I appear to get the response to (4), not (3) |
@Richard-Walton The 2nd GET (step 4 in my explanation) should not make it to your server. It's just pulling the response to your POST (step 3) from the proxy layer. I hear what you're saying, but I can't reproduce this problem unfortunately. Can you provide a minimum reproducible example? A Git repo with a server setup that shows the problem would be perfect. |
I would love to, but I'm not sure how. The app being tested is running behind a load balancer (https://www.pulsesecure.net/products/virtual-traffic-manager/) - so the setup is a little complicated. I'll have a think. So, it seems perhaps, for reasons that the 2nd request makes it to my server. Perhaps the logic in the cypress backend for determining which requests it handles / vs which ones make it to the origin is buggy? The only other bit of information I can offer is that the url I am visiting contains a query string param (http://cc2?version=)... perhaps it is relevant. |
Haha, I got it! So...my baseUrl is set to Removing the port fixes the issue. So, I assume there is some cache code which doesn't take into account the presence/lack of presence of This also would make sense as to why when I target the app directly, rather than via the LB, it works. When targeting directly I set my baseUrl to ^ Anyway, all just guess work. Right now, I can easily not append I'll keep tracking this issue if you need any more info from me. Happy to help where I can :) |
@flotwig Any thoughts on the above^ ? |
Ugh, that definitely sounds possible. The |
:80
* Add a bunch of extra tests in 2_cookies_spec * Try not doing weird things to cookies * if cypress.env.debug is set, log command execution thru server * improve elctron logging - we missed this when doing cri-client logging * make video_capture frames part of verbose * cleanup * use the data from getCookie to run deleteCookies * fix screenshots * still resolve with cleared cookie * cy.getcookie now gets ALL cookies from ALL domains * return Promise for followRedirect, not req.init wrap * allow passing domain: null to cy.getCookies to get all * update request_spec to be clearer * still need to call followRedirect option during sendStream * beautify the e2e tests * correct e2e test + snapshot * always discard default ports when get/set buffer - fixes #5367 * make cy.clearCookies({ domain: null }) clear ALL cookies * update spec * use string url as key * rebalance some e2e tests to make time for new cookies e2e tests * always add default port to buffer url * jk, remove default port * set hostOnly: true when appropriate when setting cookies back on visit * update tests * Revert "if cypress.env.debug is set, log command execution thru server" This reverts commit 623ed44. * try to clean diff, cookies_no_baseurl didnt change * WIP move the expected cookies array out of snapshot and expect inline * finish updating tests * add missing snapshot * remove useless onstdout Co-authored-by: Brian Mann <[email protected]>
The code for this is done in cypress-io/cypress#5478, but has yet to be released. |
Released in |
Current behavior:
cy.visit({ url, method, headers })
does not appear to honour themethod
, orheaders
Desired behavior:
cy.visit({ url, method, headers })
should send the specified method and headers.Steps to reproduce: (app code and test code)
I include an annotated Cypress debug log:
Changing the method to
GET
still results in the headers not being sentVersions
I tested Cypress 3.4.1 and 3.2.0.
Ubuntu LTS
Chrome 77
UPDATE: Cause tracked down to: #5367 (comment)
The text was updated successfully, but these errors were encountered: