cypress: SIGSEGV with ERR_TLS_REQUIRED_SERVER_NAME in Server.addContext

The Test Runner unexpectedly exited via a exit event with signal SIGSEGV

Please search Cypress documentation for possible solutions:

https://on.cypress.io

Check if there is a GitHub issue describing this crash:

https://github.com/cypress-io/cypress/issues

Consider opening a new issue.

----------

Platform: darwin (19.5.0)
Cypress Version: 5.6.0
GET /__cypress/tests?p=cypress/support/index.js 200 1268.985 ms - -
Error [ERR_TLS_REQUIRED_SERVER_NAME] [ERR_TLS_REQUIRED_SERVER_NAME]: "servername" is required parameter for Server.addContext
    at Server.addContext (_tls_wrap.js:1400:11)
    at /Users/gleb/Library/Caches/Cypress/5.6.0/Cypress.app/Contents/Resources/app/packages/https-proxy/lib/server.js:222:23
    at tryCatcher (/Users/gleb/Library/Caches/Cypress/5.6.0/Cypress.app/Contents/Resources/app/packages/https-proxy/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/gleb/Library/Caches/Cypress/5.6.0/Cypress.app/Contents/Resources/app/packages/https-proxy/node_modules/bluebird/js/release/promise.js:512:31)

Relevant code from packages/https-proxy/lib/server.js

  _getPortFor (hostname) {
    return this._getCertificatePathsFor(hostname)
    .catch((err) => {
      return this._generateMissingCertificates(hostname)
    }).then((data = {}) => {
      if (net.isIP(hostname)) {
        return this._getServerPortForIp(hostname, data)
      }

      this._sniServer.addContext(hostname, data) // line 222

      return this._sniPort
    })
  }

Reproduction steps:

What is happening I think: the test tries to include a script pointing at external CDN https: //cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.bundle.min.js in the iframe, which seems to crash badly.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 16 (5 by maintainers)

Most upvoted comments

The code for this is done in cypress-io/cypress#19274, but has yet to be released. We’ll update this issue and reference the changelog when it’s released.

@bahmutov - The repro steps in the opening appear to be because of a typo in your fiddle: https://github.com/cypress-io/cypress-fiddle/blob/e7baf12419b27a9f17eaac1591cab56d087366de/cypress-markdown.json#L5 - you have https: //cdn... rather than https://cdn... - notice the extra space. Removing that typo, the error no longer occurs.

With that said, it’s a very useful repro, because it exposes a bug in cypress’ http-proxy request handling.

https://github.com/cypress-io/cypress/blob/develop/packages/https-proxy/lib/server.js#L157

Is where we attempt to parse a hostname from the given URL. In certain cases, like the one described in your fiddle, this results in an empty hostname. We should probably catch this here, rather than attempting to create an ssl server with an invalid hostname and letting node throw a very ugly exception.

Found it: …\Administrator\AppData\Local\Cypress\Cache\7.4.0\Cypress\resources\app\packages\https-proxy\lib - & this worked, thanks a lot…