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

Firefox/docker: cy.setCookie() does not work #20015

Closed
con-cso opened this issue Feb 2, 2022 · 6 comments
Closed

Firefox/docker: cy.setCookie() does not work #20015

con-cso opened this issue Feb 2, 2022 · 6 comments
Labels

Comments

@con-cso
Copy link

con-cso commented Feb 2, 2022

Current behavior

(see #17539 for details)

We are running our CI using

  • one "service" docker container containing our app
  • the cypress "included" container, which accesses our app via a docker alias

With chrome and electron, this setup works perfectly fine. Firefox fails on every cy.setCookie() call, however.

Please prioritize as this completely prevents us from running Firefox tests. Thanks!

Desired behavior

cy.setCookie should work in Firefox if the domain is not "localhost".

Test code to reproduce

simply call cy.setCookie("foo", "bar") in combination with cypress run -b firefox -c baseUrl=https://${SERVICE_ALIAS}

Cypress Version

9.3.1

Other

No response

@flotwig
Copy link
Contributor

flotwig commented Feb 2, 2022

Hey @con-cso, we have a number of tests for cy.setCookie in Firefox with an HTTPS baseURL already, so there is probably something else going on here. Can you please create a reproducible example, for example by forking cypress-test-tiny, that someone can run to see this issue? It might have to do with FF version, what version are you running?

@flotwig flotwig added the stage: needs information Not enough info to reproduce the issue label Feb 2, 2022
@con-cso
Copy link
Author

con-cso commented Feb 3, 2022

Sure can, here you go:
https://github.com/con-cso/cypress-ff-cookie

@con-cso
Copy link
Author

con-cso commented Feb 11, 2022

Hi, did you manage to reproduce the behavior?
btw, the version of FF is 93 (as found in the container cypress/included:9.3.1)

@BlueWinds
Copy link
Contributor

BlueWinds commented Feb 15, 2022

Thanks for the super nice example, and I've verified that the behavior is weird as you describe. I'm going to try to dig into it in more detail tomorrow morning, just commenting now to let you know it's on my radar.

@BlueWinds
Copy link
Contributor

Ok, so here's what I have so

So the short version is that this is because of
--config baseUrl=https://foo-bar:6379/. If you change this to
--config baseUrl=https://foo-bar.baz:6379/, it will start working - anything that can be parsed as a domain name.

So the workaround is fairly simple - Add ".com" (or ".stuff" or whatever) to the end of your other container's hostname and Cypress' base URL.

The long version is that this related to https://bugzilla.mozilla.org/show_bug.cgi?id=1517993 - the error is occurring directly in Firefox when we a attempt to set a cookie on a domain that FF doesn't recognize as valid. I suspect you could reproduce this outside of docker if you registered your server to "foo-bar" in /etc/hosts, but docker is an easy way to trigger that by accident.

It would be possible to figure out exactly what's happening and add safeguards to cypress, but it's going to be fairly low on our priority list. Are you able to apply the workaround?

@con-cso
Copy link
Author

con-cso commented Feb 16, 2022

Thank you very much for looking into this! I can confirm using a domain name including a dot instead of a simple hostname resolves the issue. Since we control our CI configuration, I can implement the fix no problem.

I don't know the RFCs well enough to say whether this is a bug or a feature, but I could not find any note about this restriction in them. At least this is here now to help others running into this by accident.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants