Skip to content

Cypress app crash: "port" option should be a number or string  #3250

Closed
@rastislavkucera

Description

@rastislavkucera

Current behavior:

After login into one app, it redirects to different, when CONNECT request from %7Balgolia_application_id%7D-dsn.algolia.net:443 occurs, it crashes cypress.

cypress:server:server Got CONNECT request from %7Balgolia_application_id%7D-dsn.algolia.net:443 +2ms
  cypress:https-proxy Writing socket connection headers for URL: %7Balgolia_application_id%7D-dsn.algolia.net:443 +378ms
  cypress:server:cors Parsed URL { port: '443', tld: '', domain: '' } +4ms
  cypress:server:server HTTPS request does not match URL: https://%7Balgolia_application_id%7D-dsn.algolia.net:443 with props: { port: '9011', tld: '127.0.0.1', domain: '' } +0ms
  cypress:server:server HTTPS request https://%7Balgolia_application_id%7D-dsn.algolia.net:443 matches blacklist? undefined +1ms
  cypress:https-proxy Making direct connection to %7Balgolia_application_id%7D-dsn.algolia.net:443 +5ms
  cypress:server:file get values from /home/rasto/.config/Cypress/cy/production/cache +9ms
  cypress:server:file attempt to get lock on /home/rasto/.config/Cypress/cy/production/cache +0ms
  cypress:server:proxy received response for { url: 'http://127.0.0.1:9002/api/index/promoted-facilities', headers: { 'x-robots-tag': 'noindex', 'access-control-allow-origin': '', 'access-control-allow-credentials': '', 'access-control-allow-methods': '', 'access-control-allow-headers': '', 'access-control-expose-headers': '', 'content-type': 'application/json; charset=utf-8', 'content-length': '32', date: 'Wed, 30 Jan 2019 12:37:00 GMT', connection: 'close' }, statusCode: 200, isGzipped: undefined, wantsInjection: false, wantsSecurityRemoved: false } +2ms
GET /api/index/promoted-facilities 200 32.515 ms - -
  cypress:server:file gettin lock succeeded or failed for /home/rasto/.config/Cypress/cy/production/cache +3ms
  cypress:server:file read /home/rasto/.config/Cypress/cy/production/cache +0ms
  cypress:server:file read succeeded or failed for /home/rasto/.config/Cypress/cy/production/cache +0ms
  cypress:server:file attempt to unlock /home/rasto/.config/Cypress/cy/production/cache +1ms
  cypress:server:timers queuing timer id 84 after 2000 ms +0ms
  cypress:server:timers clearing timer id 84 from queue { '7': { args: [], ms: 2500, cb: [Function: cb] }, '55': { args: [], ms: 85000, cb: [Function] }, '56': { args: [], ms: 60000, cb: [Function: timeoutTimeout] }, '84': { args: [], ms: 2000, cb: [Function: timeoutTimeout] } } +0ms
  cypress:server:file unlock succeeded or failed for /home/rasto/.config/Cypress/cy/production/cache +0ms
  cypress:server:timers child received timer id 84 +23ms
  cypress:server:api request to url: POST https://api.cypress.io/exceptions with params: {"body":{"err":{"name":"TypeError","message":"\"port\" option should be a number or string: function () {\n        socket.pipe(conn);\n        conn.pipe(socket);\n        socket.emit(\"data\", head);\n        return socket.resume();\n      }","stack":"TypeError: \"port\" option should be a number or string: function () {\n        socket.pipe(conn);\n        conn.pipe(socket);\n        socket.emit(\"data\", head);\n        return socket.resume();\n      }\n    at lookupAndConnect (net.js:1019:13)\n    at Socket.connect (net.js:995:5)\n    at Object.connect (net.js:108:35)\n    at Server._makeConnection (<stripped-path>server.js:109:26)\n    at Server._makeDirectConnection (<stripped-path>server.js:95:19)\n    at Server.connect (<stripped-path>server.js:59:25)\n    at Socket.<anonymous> (<stripped-path>server.js:46:26)\n    at Object.onceWrapper (events.js:316:30)\n    at emitOne (events.js:115:13)\n    at Socket.emit (events.js:210:7)\n    at addChunk (_stream_readable.js:252:12)\n    at readableAddChunk (_stream_readable.js:239:11)\n    at Socket.Readable.push (_stream_readable.js:197:10)\n    at TCP.onread (net.js:589:20)\n"},"version":"3.1.4","osName":"linux","osVersion":"Arch Linux - ","osCpus":[{"model":"Intel(R) Core(TM) i3-6100U CPU @ 2.30GHz","speed":1034,"times":{"user":64062700,"nice":1949300,"sys":23324900,"idle":218176300,"irq":3361500}},{"model":"Intel(R) Core(TM) i3-6100U CPU @ 2.30GHz","speed":1074,"times":{"user":64656500,"nice":1964100,"sys":23417700,"idle":114683700,"irq":2280800}},{"model":"Intel(R) Core(TM) i3-6100U CPU @ 2.30GHz","speed":1094,"times":{"user":65491000,"nice":1982300,"sys":23412100,"idle":114960100,"irq":2832600}},{"model":"Intel(R) Core(TM) i3-6100U CPU @ 2.30GHz","speed":1078,"times":{"user":64894000,"nice":1980900,"sys":23275400,"idle":115509200,"irq":1830600}}],"osMemory":{"free":1750638592,"total":12300214272}},"headers":{"x-os-name":"linux","x-cypress-version":"3.1.4"}} +14ms
  cypress:server:timers queuing timer id 85 after 3000 ms +7ms
  cypress:server:timers child received timer id 85 +21ms
  cypress:server:timers clearing timer id 85 from queue { '7': { args: [], ms: 2500, cb: [Function: cb] }, '55': { args: [], ms: 85000, cb: [Function] }, '56': { args: [], ms: 60000, cb: [Function: timeoutTimeout] }, '85': { args: [], ms: 3000, cb: [Function: timeoutTimeout] } } +0ms
TypeError: "port" option should be a number or string: function () {
        socket.pipe(conn);
        conn.pipe(socket);
        socket.emit("data", head);
        return socket.resume();
      }
    at lookupAndConnect (net.js:1019:13)
    at Socket.connect (net.js:995:5)
    at Object.connect (net.js:108:35)
    at Server._makeConnection (/home/rasto/.cache/Cypress/3.1.4/Cypress/resources/app/packages/https-proxy/lib/server.js:109:26)
    at Server._makeDirectConnection (/home/rasto/.cache/Cypress/3.1.4/Cypress/resources/app/packages/https-proxy/lib/server.js:95:19)
    at Server.connect (/home/rasto/.cache/Cypress/3.1.4/Cypress/resources/app/packages/https-proxy/lib/server.js:59:25)
    at Socket.<anonymous> (/home/rasto/.cache/Cypress/3.1.4/Cypress/resources/app/packages/https-proxy/lib/server.js:46:26)
    at Object.onceWrapper (events.js:316:30)
    at emitOne (events.js:115:13)
    at Socket.emit (events.js:210:7)
    at addChunk (_stream_readable.js:252:12)
    at readableAddChunk (_stream_readable.js:239:11)
    at Socket.Readable.push (_stream_readable.js:197:10)
    at TCP.onread (net.js:589:20)

TypeError: "port" option should be a number or string: function () {
        socket.pipe(conn);
        conn.pipe(socket);
        socket.emit("data", head);
        return socket.resume();
      }
    at lookupAndConnect (net.js:1019:13)
    at Socket.connect (net.js:995:5)
    at Object.connect (net.js:108:35)
    at Server._makeConnection (/home/rasto/.cache/Cypress/3.1.4/Cypress/resources/app/packages/https-proxy/lib/server.js:109:26)
    at Server._makeDirectConnection (/home/rasto/.cache/Cypress/3.1.4/Cypress/resources/app/packages/https-proxy/lib/server.js:95:19)
    at Server.connect (/home/rasto/.cache/Cypress/3.1.4/Cypress/resources/app/packages/https-proxy/lib/server.js:59:25)
    at Socket.<anonymous> (/home/rasto/.cache/Cypress/3.1.4/Cypress/resources/app/packages/https-proxy/lib/server.js:46:26)
    at Object.onceWrapper (events.js:316:30)
    at emitOne (events.js:115:13)
    at Socket.emit (events.js:210:7)
    at addChunk (_stream_readable.js:252:12)
    at readableAddChunk (_stream_readable.js:239:11)
    at Socket.Readable.push (_stream_readable.js:197:10)
    at TCP.onread (net.js:589:20)

  cypress:server:browsers killing browser process +14ms

Desired behavior:

Should not crash cypress

Steps to reproduce: (app code and test code)

test code:

describe('Multi-domain test', () =>{
describe('Auth login', () => {
    it('login', () => {
      cy.visit('http://127.0.0.1:9011/')

      cy.get('input[name="email"]').type('e@mail.com')
      cy.get('input[name="password"]').type('password')
      cy.get('[type="submit"]').click()
    })
  })
describe('Visit different app', () => {
    it('go do smhting', () => {
      cy.visit('http://127.0.0.1:9002/')
    })
  })
})

App code:

Cant provide right now ...

It is fixed if i add if(port === null){port = 443} on line 100 of ~/.cache/Cypress/3.1.4/Cypress/resources/app/packages/https-proxy/lib/server.js

I am using "chromeWebSecurity": false, I do not want to use request for login ...

Versions

Cypress 3.1.4 , arch linux

Activity

simonireilly

simonireilly commented on Aug 2, 2019

@simonireilly

Can confirm that the above fix works still in Cypress 3.20, is this issue near resolution?

self-assigned this
on Aug 2, 2019
flotwig

flotwig commented on Aug 2, 2019

@flotwig
Contributor

Got a fix in #4916, should be out with the next release.

cypress-bot

cypress-bot commented on Aug 2, 2019

@cypress-bot
Contributor

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

cypress-bot

cypress-bot commented on Oct 23, 2019

@cypress-bot
Contributor

Released in 3.5.0.

locked as resolved and limited conversation to collaborators on Jan 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Participants

    @flotwig@jennifer-shehane@simonireilly@rastislavkucera

    Issue actions

      Cypress app crash: "port" option should be a number or string · Issue #3250 · cypress-io/cypress