Cypress: Url with underscore in subdomain is not working

Created on 23 May 2019  路  7Comments  路  Source: cypress-io/cypress

Current behavior:

We have an project environment like this:
https://opt_in_opt_out.bzr.project.independer.nl

If I start the runner and select any script the page stays empty.

image

Desired behavior:

Just run the scripts just like normal

Steps to reproduce: (app code and test code)

Make a project environment with _ (underscores) in it.
Run a script against it

Versions

Cypress: 3.0.1
Windows 7
Chrome 74.0.3729.169

proposal 馃挕 unexpected behavior

Most helpful comment

@Niceplace The Stackoverflow question and the RFC referenced in it RFC3986#section-3.1 refers to the scheme part of the URL.

So my understanding is that it's perfectly legal for the rest of the URL to can contain an _ as explained in here RFC2181#section-11

So this looks like a bug in Cypress.

All 7 comments

@bvanderneut Sorry, I'm having a hard time following what exactly you are doing.

  • Are there any errors shown in the DevTools?
  • Could you provide the test code you are running?
  • Also, where/how are you setting this project environment?
  • Where are you selecting this 'script'?

Also, please try upgrading to 3.3.1 first. Your issue may already be resolved.

There are no errors shown in the devtools, console or terminal

baseurl is https://opt_in_opt_out.bzr.project.independer.nl
script just does this

describe('Check newsletter functionality', () => {
  beforeEach(function () {
    cy.fixture('Algemeen/persoonsgegevens.json').as('persoonsgegevens');
  });

  it('Check if redirect works', function () {
    cy.visit('/gegevens/aanmelden.aspx');
    cy.url().should('contain', '/gegevens/voorkeuren');

    cy.visit('/gegevens/afmelden.aspx');
    cy.url().should('contain', '/gegevens/voorkeuren');
  });
});

We deploy our site with TFS if that's what you mean. But if I deploy the same repository to an other url like https://newsletter.bzr.project.independer.nl it works fine.

I am running them from the runner it self. Also running them headless in the terminal is not working. There it gives the message "Timed out waiting for the browser to connect. Retrying..." and then after that "The browser never connected. Something is wrong. The tests cannot run. Aborting..."

Just tested with the 3.3.1 version but the same result.

@bvanderneut Having the same issue here with 4.2.0. ~I did a bit of digging and apparently underscores in URL is not supported by the spec ! Mentionned here: https://stackoverflow.com/questions/9142309/may-url-scheme-contain-an-underscore with reference to: https://tools.ietf.org/html/rfc3986#page-171~ Edit: This is wrong and only refers to the scheme part of the URL, thanks @kenjiru

We have sanitized URLs for our feature deployments and it basically creates a URL using the branch name, with some character substitution. One of our branch was failing cypress with a repeating pattern:

Timed out waiting for the browser to connect. Retrying...

Timed out waiting for the browser to connect. Retrying again...

The browser never connected. Something is wrong. The tests cannot run. Aborting...

Digging into the logs (set env variable DEBUG to "*" when running cypress), I was able to find three instances of these messages at roughly 1 minute interval each:

2020-03-26T02:38:35.4425329Z   cypress:launcher chrome stderr: [0326/023835.439101:ERROR:ssl_client_socket_impl.cc(941)] handshake failed; returned -1, SSL error code 1, net_error -167 +6s
2020-03-26T02:38:35.4441516Z   cypress:server:util:socket_whitelist whitelisted socket closed, removing { localPort: 52164 } +7ms
2020-03-26T02:38:35.4449098Z   cypress-verbose:server:browsers:cri-client:recv:[<--] received CDP message { id: 3, result: { frameId: '2C1E4805A4374E81E017D24F50AAFFA7', loaderId: '6F437AF6F6C13636A11E5589EFB17A74', errorText: 'net::ERR_SSL_SERVER_CERT_BAD_FORMAT' } } +2s

Followed by, a few moments later, chrome being terminated

2020-03-26T02:41:27.8999786Z   cypress:server:browsers killing browser process +60s
2020-03-26T02:41:27.9000767Z   cypress:server:browsers:chrome closing remote interface client +60s
2020-03-26T02:41:27.9005437Z   cypress:server:browsers:chrome closing chrome +2ms
2020-03-26T02:41:27.9258953Z   cypress:launcher chrome exited: { code: null, signal: 'SIGTERM' } +60s
2020-03-26T02:41:27.9294869Z   cypress:server:browsers browser process killed +24ms
2020-03-26T02:41:27.9295774Z The browser never connected. Something is wrong. The tests cannot run. Aborting...
2020-03-26T02:41:27.9298696Z onError is not a function
2020-03-26T02:41:27.9299455Z TypeError: onError is not a function
2020-03-26T02:41:27.9300311Z     at /home/runner/.cache/Cypress/4.2.0/Cypress/resources/app/packages/server/lib/modes/run.js:1036:11
2020-03-26T02:41:27.9302706Z     at tryCatcher (/home/runner/.cache/Cypress/4.2.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
2020-03-26T02:41:27.9304148Z     at Promise._settlePromiseFromHandler (/home/runner/.cache/Cypress/4.2.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise.js:547:31)
2020-03-26T02:41:27.9307190Z     at Promise._settlePromise (/home/runner/.cache/Cypress/4.2.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise.js:604:18)
2020-03-26T02:41:27.9308681Z     at Promise._settlePromise0 (/home/runner/.cache/Cypress/4.2.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise.js:649:10)
2020-03-26T02:41:27.9310027Z     at Promise._settlePromises (/home/runner/.cache/Cypress/4.2.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise.js:729:18)
2020-03-26T02:41:27.9311373Z     at _drainQueueStep (/home/runner/.cache/Cypress/4.2.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/async.js:93:12)
2020-03-26T02:41:27.9312672Z     at _drainQueue (/home/runner/.cache/Cypress/4.2.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/async.js:86:9)
2020-03-26T02:41:27.9314292Z     at Async._drainQueues (/home/runner/.cache/Cypress/4.2.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/async.js:102:5)
2020-03-26T02:41:27.9315490Z     at Immediate.Async.drainQueues [as _onImmediate] (/home/runner/.cache/Cypress/4.2.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/async.js:15:14)
2020-03-26T02:41:27.9316186Z     at processImmediate (internal/timers.js:439:21)
2020-03-26T02:41:27.9316758Z 
2020-03-26T02:41:27.9317347Z   cypress:server:cypress exiting with err TypeError: onError is not a function
2020-03-26T02:41:27.9317912Z     at /home/runner/.cache/Cypress/4.2.0/Cypress/resources/app/packages/server/lib/modes/run.js:1036:11
2020-03-26T02:41:27.9318530Z     at tryCatcher (/home/runner/.cache/Cypress/4.2.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
2020-03-26T02:41:27.9319344Z     at Promise._settlePromiseFromHandler (/home/runner/.cache/Cypress/4.2.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise.js:547:31)
2020-03-26T02:41:27.9320115Z     at Promise._settlePromise (/home/runner/.cache/Cypress/4.2.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise.js:604:18)
2020-03-26T02:41:27.9320871Z     at Promise._settlePromise0 (/home/runner/.cache/Cypress/4.2.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise.js:649:10)
2020-03-26T02:41:27.9321615Z     at Promise._settlePromises (/home/runner/.cache/Cypress/4.2.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise.js:729:18)
2020-03-26T02:41:27.9322351Z     at _drainQueueStep (/home/runner/.cache/Cypress/4.2.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/async.js:93:12)
2020-03-26T02:41:27.9323084Z     at _drainQueue (/home/runner/.cache/Cypress/4.2.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/async.js:86:9)
2020-03-26T02:41:27.9323835Z     at Async._drainQueues (/home/runner/.cache/Cypress/4.2.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/async.js:102:5)
2020-03-26T02:41:27.9324634Z     at Immediate.Async.drainQueues [as _onImmediate] (/home/runner/.cache/Cypress/4.2.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/async.js:15:14)
2020-03-26T02:41:27.9325237Z     at processImmediate (internal/timers.js:439:21)
2020-03-26T02:41:27.9325788Z  +3m

I was able to recreate the issue locally, running against a URL with an underscore in it. Running against the same application code but without an underscore in the URL made the error go away.

Fun investigation ! I think we could benefit of a clearer error message in that case (pre-flight check before starting the browser maybe ?) but at the root, it seems underscores should not be part of url domains (or sub-domains).

Cheers and happy debugging :D !

cc: @jennifer-shehane

@Niceplace The Stackoverflow question and the RFC referenced in it RFC3986#section-3.1 refers to the scheme part of the URL.

So my understanding is that it's perfectly legal for the rest of the URL to can contain an _ as explained in here RFC2181#section-11

So this looks like a bug in Cypress.

@kenjiru I think that's backwards. Domains outside of URLs can include underscores - as the SO answer mentions, "Domains with underscores are very common in the wild. Check _jabber._tcp.gmail.com or _sip._udp.apnic.net.".

However, domains inside URLs cannot include underscores. Notice that the above domains are not meant to be visited via URL, they're for DNS-based service discovery only.

So even though it works in some web browsers, it's technically not valid, so you may wish to update your domains at some point in the future to not include underscores.


I agree that Cypress should be patched to allow underscores in domains though, since the behavior should not differ from the behavior of a real browser.

Is there any fix or workaround found by cypress team? We cannot tell the world to fix their URL's always, there should be fix in cypress.

@niraj-nagtilak1990 We do not recommend testing websites that you do not directly control. https://on.cypress.io/best-practices#Visiting-external-sites

There are no current workarounds.

Was this page helpful?
0 / 5 - 0 ratings