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

SIGSEGV with ERR_TLS_REQUIRED_SERVER_NAME in Server.addContext #9220

Closed
bahmutov opened this issue Nov 16, 2020 · 16 comments · Fixed by #19186 or #19274
Closed

SIGSEGV with ERR_TLS_REQUIRED_SERVER_NAME in Server.addContext #9220

bahmutov opened this issue Nov 16, 2020 · 16 comments · Fixed by #19186 or #19274
Assignees
Labels
topic: SIG errors Program error signals, ie SIGILL, SIGSEGV, SIGBUS, SIGABRT type: bug type: error message

Comments

@bahmutov
Copy link
Contributor

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.

@bahmutov bahmutov added topic: SIG errors Program error signals, ie SIGILL, SIGSEGV, SIGBUS, SIGABRT type: bug labels Nov 16, 2020
@cypress-bot cypress-bot bot added the stage: needs investigating Someone from Cypress needs to look at this label Nov 17, 2020
@bahmutov
Copy link
Contributor Author

More relevant logs

$ DEBUG=cypress:https-proxy npm run cy:md

> @cypress/fiddle@0.0.0-development cy:md /Users/gleb/git/cypress-fiddle
> cypress open --config-file cypress-markdown.json

  cypress:https-proxy Created SNI HTTPS Proxy Server { port: 53618 } +0ms
GET /__/ 200 9.035 ms - -
GET /__cypress/runner/cypress_runner.css 200 3.791 ms - -
GET /__cypress/runner/cypress_runner.js 200 1.796 ms - -
  cypress:https-proxy Writing browserSocket connection headers { url: 'localhost:53616', headLength: 0, headers: { host: 'localhost:53616', 'proxy-connection': 'keep-alive', 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Cypress/5.6.0 Chrome/85.0.4183.121 Electron/10.1.5 Safari/537.36' } } +3s
  cypress:https-proxy Got first head bytes { url: 'localhost:53616', head: 'GET /__socket.io/?EIO=3&transport=websocket HTTP/1.1\r\nHost: loca' } +4ms
  cypress:https-proxy Making intercepted connection to 53616 +0ms
  cypress:https-proxy received upstreamSocket callback for request { port: 53616, hostname: 'localhost', err: undefined } +1ms
GET /__cypress/iframes/integration/contains-example.md 200 2.715 ms - 902
GET /__cypress/runner/fonts/fa-solid-900.woff2 200 1.184 ms - 76120
Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db
GET /__cypress/tests?p=cypress/integration/contains-example.md 200 1196.854 ms - -
GET /__cypress/tests?p=cypress/support/index.js 200 1234.019 ms - -
  cypress:https-proxy Writing browserSocket connection headers { url: 'cdnjs.cloudflare.com:443', headLength: 0, headers: { host: 'cdnjs.cloudflare.com:443', 'proxy-connection': 'keep-alive', 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Cypress/5.6.0 Chrome/85.0.4183.121 Electron/10.1.5 Safari/537.36' } } +2s
  cypress:https-proxy Writing browserSocket connection headers { url: 'code.jquery.com:443', headLength: 0, headers: { host: 'code.jquery.com:443', 'proxy-connection': 'keep-alive', 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Cypress/5.6.0 Chrome/85.0.4183.121 Electron/10.1.5 Safari/537.36' } } +1ms
  cypress:https-proxy Got first head bytes { url: 'cdnjs.cloudflare.com:443', head: '\u0016\u0003\u0001\u0002\u0000\u0001\u0000\u0001�\u0003\u0003��5S\b.\u000e��<�r�b�\u0003\u0019n��N�R��i�22�=H ��̕��\u0003��!�@/l�\u0014�!\u0013�\r' } +1ms
  cypress:https-proxy Got first head bytes { url: 'code.jquery.com:443', head: '\u0016\u0003\u0001\u0002\u0000\u0001\u0000\u0001�\u0003\u0003\u0000�\u0006n;\u0004�A��H�Y��\u0010�׽���a�\u001c�\bh\u001b�Q� �pGS�hC��$J V�\t�9qڶ�' } +1ms
  cypress:https-proxy Writing browserSocket connection headers { url: '%20:443', headLength: 0, headers: { host: '%20:443', 'proxy-connection': 'keep-alive', 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Cypress/5.6.0 Chrome/85.0.4183.121 Electron/10.1.5 Safari/537.36' } } +1ms
  cypress:https-proxy Got first head bytes { url: '%20:443', head: '\u0016\u0003\u0001\u0002\u0000\u0001\u0000\u0001�\u0003\u0003�xG�\u0018\u0014Z4\fЙ�U�e��\u001eD�I�\u0017�ul\t��\u001a� ��p�\u0018x�۷�Jd�6�\u00004��\u000e?�' } +0ms
  cypress:https-proxy Making intercepted connection to 53618 +2ms
  cypress:https-proxy Making intercepted connection to 53618 +1ms
  cypress:https-proxy received upstreamSocket callback for request { port: 53618, hostname: 'localhost', err: undefined } +0ms
  cypress:https-proxy received upstreamSocket callback for request { port: 53618, hostname: 'localhost', err: undefined } +1ms
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)

@rharmaning
Copy link

rharmaning commented Dec 21, 2020

I'm hitting the same error. Recently upgraded my system to Catalina (tests on Mojave were running). Failing on Cypress 6.1.0 and now 6.2.0 as well. Blocks all test runs for me.

update: I'm getting the same error on another MacBook just updated to Big Sur

@HoracePGreeley
Copy link

I get the same error by running the tests on the Gitlab pipeline. The docker image cypress/browsers:node14.15.0-chrome86-ff82 is in use and the tests are executed in a headless chrome. Locally on my MacBook, all tests run successful.

@Emilemuny
Copy link

For those encountering this issue and is a blocker, here's a workaround I've added that seem to resolve the issue for now until it is officially fixed 👍

Go to the server.js file of the https-proxy package and add the below code right above this._sniServer.addContext(hostname, data).

if(hostname === '') { hostname = 'example.com'; // Used my SUT url in my case. };

@Aishwarya-UR
Copy link

Hi @Emilemuny - where can I find the https-proxy package you mentioned?

@Aishwarya-UR
Copy link

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

@porkus1990
Copy link

Hi

is there any update on this? Have the same issue now and editing the lib is no option on CI.

@tarponjargon
Copy link

tarponjargon commented Aug 31, 2021

This just started happening to me yesterday on alot of my tests. Specifically, I'm testing that clicking a specific button will direct the user to a paypal login. On every test that does that, it crashes out after loading the paypal page with:

Error [ERR_TLS_REQUIRED_SERVER_NAME] [ERR_TLS_REQUIRED_SERVER_NAME]: "servername" is required parameter for Server.addContext

@porkus1990
Copy link

This just started happening to me yesterday on alot of my tests. Specifically, I'm testing that clicking a specific button will direct the user to a paypal login. On every test that does that, it crashes out after loading the paypal page with:

Error [ERR_TLS_REQUIRED_SERVER_NAME] [ERR_TLS_REQUIRED_SERVER_NAME]: "servername" is required parameter for Server.addContext

Same for me - checked it again: happens only for PayPal requests with cypress.

@giyeonkwon
Copy link

Same here. It happens only after PayPal requests with cypress.
Also, my cypress runner fails to connect to the browsers after this issue occurs in my local env.

image

@alxndr
Copy link

alxndr commented Oct 15, 2021

This error occurred for hours yesterday on CircleCI, then resolved itself; it has started occurring again today. This is a detailed test suite (>30 test files) for a work project, a React-based CMS which talks to a couple of different back-ends using CORS requests. Many of the tests pass, then this error occurs about halfway through the test suite, at a specific test which does not appear to be doing anything unusual in the setup or assertions.

versions...

  • Cypress: 8.3.1 and also 8.6.0
  • Node: 14.17.3
  • npm: 7.20.6
  • Cypress Orb for CircleCI... cypress/base:12.19.0
  • Ubuntu 18.04.5 LTS
  • Browser: Electron 91 (headless)

Locally I can run the test which fails on CircleCI and it passes, however my local setup is using Electron 93 (headless), so perhaps the browser version is the issue?

@alxndr
Copy link

alxndr commented Nov 5, 2021

This error popped up again today about six hours ago and is still happening. I enabled debugging with cypress:network:* and here's the output just before the ERR_TLS_REQUIRED_SERVER_NAME. The lines about port 45525 surprise me, as the site under test is running on localhost:2222, and the requests it makes are mostly over 443 with an occasional use of 80...

  cypress:network:cors Parsed URL { port: '443', tld: 'com', domain: '**************' } +20ms
  cypress:network:connect successfully connected { opts: { port: 45525, host: 'localhost', getDelayMsForRetry: [Function: getDelayForRetry] }, iteration: 0 } +617ms
  cypress:network:connect successfully connected { opts: { port: 45525, host: 'localhost', getDelayMsForRetry: [Function: getDelayForRetry] }, iteration: 0 } +36ms
  cypress:network:connect successfully connected { opts: { port: 45525, host: 'localhost', getDelayMsForRetry: [Function: getDelayForRetry] }, iteration: 0 } +0ms
Error [ERR_TLS_REQUIRED_SERVER_NAME] [ERR_TLS_REQUIRED_SERVER_NAME]: "servername" is required parameter for Server.addContext
    at Server.addContext (_tls_wrap.js:1423:11)
    at /root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/https-proxy/lib/server.js:231:23
    at tryCatcher (/root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/https-proxy/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/https-proxy/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/https-proxy/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/https-proxy/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/https-proxy/node_modules/bluebird/js/release/promise.js:694:18)
    at Promise._fulfill (/root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/https-proxy/node_modules/bluebird/js/release/promise.js:638:18)
    at Promise._resolveCallback (/root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/https-proxy/node_modules/bluebird/js/release/promise.js:432:57)
    at Promise._settlePromiseFromHandler (/root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/https-proxy/node_modules/bluebird/js/release/promise.js:524:17)
    at Promise._settlePromise (/root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/https-proxy/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/https-proxy/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/https-proxy/node_modules/bluebird/js/release/promise.js:694:18)
    at Promise._fulfill (/root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/https-proxy/node_modules/bluebird/js/release/promise.js:638:18)
    at PromiseArray._resolve (/root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/https-proxy/node_modules/bluebird/js/release/promise_array.js:126:19)
    at PromiseArray._promiseFulfilled (/root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/https-proxy/node_modules/bluebird/js/release/promise_array.js:144:14)
    at PromiseArray._iterate (/root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/https-proxy/node_modules/bluebird/js/release/promise_array.js:114:31)
    at PromiseArray.init [as _init] (/root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/https-proxy/node_modules/bluebird/js/release/promise_array.js:78:10)
    at Promise._settlePromise (/root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/https-proxy/node_modules/bluebird/js/release/promise.js:566:21)
    at Promise._settlePromise0 (/root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/https-proxy/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/https-proxy/node_modules/bluebird/js/release/promise.js:694:18)
    at Promise._fulfill (/root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/https-proxy/node_modules/bluebird/js/release/promise.js:638:18)
    at Promise._resolveCallback (/root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/https-proxy/node_modules/bluebird/js/release/promise.js:432:57)
    at Promise._settlePromiseFromHandler (/root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/https-proxy/node_modules/bluebird/js/release/promise.js:524:17)
    at Promise._settlePromise (/root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/https-proxy/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/https-proxy/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/https-proxy/node_modules/bluebird/js/release/promise.js:694:18)
    at Promise._fulfill (/root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/https-proxy/node_modules/bluebird/js/release/promise.js:638:18)
    at PromiseArray._resolve (/root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/https-proxy/node_modules/bluebird/js/release/promise_array.js:126:19)
    at PromiseArray._promiseFulfilled (/root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/https-proxy/node_modules/bluebird/js/release/promise_array.js:144:14)
    at Promise._settlePromise (/root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/https-proxy/node_modules/bluebird/js/release/promise.js:574:26)
    at Promise._settlePromise0 (/root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/https-proxy/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/https-proxy/node_modules/bluebird/js/release/promise.js:694:18)
    at Promise._fulfill (/root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/https-proxy/node_modules/bluebird/js/release/promise.js:638:18)
    at /root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/https-proxy/node_modules/bluebird/js/release/nodeback.js:42:21
    at /root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/https-proxy/node_modules/graceful-fs/graceful-fs.js:143:16
    at /root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/server/node_modules/graceful-fs/graceful-fs.js:111:16
    at /root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/network/node_modules/graceful-fs/graceful-fs.js:61:14
    at /root/.cache/Cypress/8.7.0/Cypress/resources/app/packages/server/node_modules/graceful-fs/graceful-fs.js:45:10
    at FSReqCallback.oncomplete (fs.js:180:23)

@BlueWinds
Copy link
Contributor

@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.

@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review stage: work in progress and removed stage: work in progress stage: needs review The PR code is done & tested, needs review labels Dec 3, 2021
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Dec 6, 2021

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

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Dec 7, 2021

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.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Dec 21, 2021

Released in 9.2.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v9.2.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Dec 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
topic: SIG errors Program error signals, ie SIGILL, SIGSEGV, SIGBUS, SIGABRT type: bug type: error message
Projects
None yet