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

3.3.1 - cypress often fails to load in open mode - websocket error #4366

Closed
lukeapage opened this issue Jun 3, 2019 · 22 comments
Closed

3.3.1 - cypress often fails to load in open mode - websocket error #4366

lukeapage opened this issue Jun 3, 2019 · 22 comments
Assignees

Comments

@lukeapage
Copy link
Contributor

Current behavior:

image

Desired behavior:

No error

Steps to reproduce: (app code and test code)

This happens intermittently but very often on 3.3.1. If you log off and on again it is fine.

If you switch back to cypress 3.3.0, even without logging off it is fine.

Versions

3.3.1 (3.3.0 is fine)
OS: windows

Most of us use proxies, usually fiddler. When 3.3.0 was release we had to have this:

$ env | grep PROXY
HTTP_PROXY=http://127.0.0.1:8888
NO_PROXY=undefined
HTTPS_PROXY=http://127.0.0.1:8888 (edited) 

One of our devs reckons the following proxy settings in 3.3.1 fix this bug:

$ env | grep -i proxy
HTTP_PROXY=
NO_PROXY=undefined
HTTPS_PROXY=

I believe the NO_PROXY needing "undefined" was due to another bug you had in your network code.

@lukeapage
Copy link
Contributor Author

lukeapage commented Jun 3, 2019

maybe this is the same as this? #4359 (comment)

If so...

I've tried with or without the base url and same error.

CYPRESS_BASE_URL=http://localhost
CYPRESS_PORT=2222

I only use the above env variables to stop cypress having an annoying reload every time you open a spec.

@flotwig
Copy link
Contributor

flotwig commented Jun 4, 2019

@lukeapage Can you share the full DEBUG logs from when you run in to this error? Here are some instructions to obtain them.

@lukeapage
Copy link
Contributor Author

I've asked my colleague to send details to support@cypress when he's back from vacation

@cypress-bot cypress-bot bot added the stage: awaiting response Potential fix was proposed; awaiting response label Jun 7, 2019
@flotwig
Copy link
Contributor

flotwig commented Jun 7, 2019

Okay, sounds good.

If anyone else reading this is experiencing this, please share your DEBUG logs to shed some light on the issue.

@flotwig
Copy link
Contributor

flotwig commented Jun 28, 2019

@lukeapage Can you to try Cypress 3.3.2? We made some bugfixes to websockets along with other network improvements and it might fix this issue.

No NO_PROXY should be necessary, though you might want to have the basic NO_PROXY=localhost just so requests for your app don't go through the proxy.

@shaharkazaz
Copy link

I got the same error not sometimes but always when working with v3.2.0 and above, I downgraded to 3.1.5 and it's working now.
Any idea where this is coming from?

@flotwig
Copy link
Contributor

flotwig commented Jul 8, 2019

@shaharkazaz No idea yet. Since you can reliably get this to happen, can you share the full debug logs from when you run Cypress and experience this issue? It would help a lot to debug the cause of this and get it fixed.

@jennifer-shehane
Copy link
Member

@shaharkazaz Any updates on sending the debug logs?

@shaharkazaz
Copy link

@flotwig @jennifer-shehane Hey, sorry I wasn't available in the last couple of days, I'll get the logs today

@shaharkazaz
Copy link

@jennifer-shehane @flotwig
These are the logs I got in the terminal (used DEBUG=cypress:* cypress open), it's a bit longer but looks like it's the same set of messages.

cypress:https-proxy received upstreamSocket callback for request { port: '50012', hostname: 'localhost', err: { Error: connect ECONNREFUSED ::1:50012 at Object._errnoException (util.js:1024:11) at _exceptionWithHostPort (util.js:1046:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14) code: 'ECONNREFUSED', errno: 'ECONNREFUSED', syscall: 'connect', address: '::1', port: 50012 } } +519ms
  cypress:https-proxy received error on client browserSocket { err: { Error: connect ECONNREFUSED ::1:50012 at Object._errnoException (util.js:1024:11) at _exceptionWithHostPort (util.js:1046:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14) code: 'ECONNREFUSED', errno: 'ECONNREFUSED', syscall: 'connect', address: '::1', port: 50012 }, url: 'localhost:50012' } +1ms
  cypress:server:server Got CONNECT request from localhost:4200 +3s
  cypress:https-proxy Writing browserSocket connection headers { url: 'localhost:4200', headLength: 0, headers: { host: 'localhost:4200', 'proxy-connection': 'keep-alive', 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36' } } +3s
  cypress:https-proxy Got first head bytes { url: 'localhost:4200', head: 'GET /__socket.io/?EIO=3&transport=websocket HTTP/1.1\r\nHost: loca' } +2ms
  cypress:server:cors Parsed URL { port: '4200', tld: 'localhost', domain: '' } +3s
  cypress:server:server HTTPS request does match URL: https://localhost:4200 with props: { port: '4200', tld: 'localhost', domain: '' } +2ms
  cypress:https-proxy Not making direct connection { url: 'localhost:4200' } +0ms
  cypress:https-proxy Making intercepted connection to 50012 +0ms
  cypress:https-proxy getting proxy URL { port: 50012, serverPort: 50012, sniPort: 50014, url: 'https://localhost:50012' } +0ms
  cypress:network:connect received error on connect, retrying { iteration: 0, delay: 0, err: { Error: connect ECONNREFUSED ::1:50012 at Object._errnoException (util.js:1024:11) at _exceptionWithHostPort (util.js:1046:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14) code: 'ECONNREFUSED', errno: 'ECONNREFUSED', syscall: 'connect', address: '::1', port: 50012 } } +3s
  cypress:network:connect received error on connect, retrying { iteration: 1, delay: 100, err: { Error: connect ECONNREFUSED ::1:50012 at Object._errnoException (util.js:1024:11) at _exceptionWithHostPort (util.js:1046:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14) code: 'ECONNREFUSED', errno: 'ECONNREFUSED', syscall: 'connect', address: '::1', port: 50012 } } +4ms
  cypress:network:connect received error on connect, retrying { iteration: 2, delay: 200, err: { Error: connect ECONNREFUSED ::1:50012 at Object._errnoException (util.js:1024:11) at _exceptionWithHostPort (util.js:1046:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14) code: 'ECONNREFUSED', errno: 'ECONNREFUSED', syscall: 'connect', address: '::1', port: 50012 } } +107ms
  cypress:network:connect received error on connect, retrying { iteration: 3, delay: 200, err: { Error: connect ECONNREFUSED ::1:50012 at Object._errnoException (util.js:1024:11) at _exceptionWithHostPort (util.js:1046:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14) code: 'ECONNREFUSED', errno: 'ECONNREFUSED', syscall: 'connect', address: '::1', port: 50012 } } +204ms
  cypress:network:connect retries exhausted, bubbling up error { iteration: 4, err: { Error: connect ECONNREFUSED ::1:50012 at Object._errnoException (util.js:1024:11) at _exceptionWithHostPort (util.js:1046:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14) code: 'ECONNREFUSED', errno: 'ECONNREFUSED', syscall: 'connect', address: '::1', port: 50012 } } +206ms
  cypress:https-proxy received upstreamSocket callback for request { port: 50012, hostname: 'localhost', err: { Error: connect ECONNREFUSED ::1:50012 at Object._errnoException (util.js:1024:11) at _exceptionWithHostPort (util.js:1046:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14) code: 'ECONNREFUSED', errno: 'ECONNREFUSED', syscall: 'connect', address: '::1', port: 50012 } } +524ms
  cypress:https-proxy received error on client browserSocket { err: { Error: connect ECONNREFUSED ::1:50012 at Object._errnoException (util.js:1024:11) at _exceptionWithHostPort (util.js:1046:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14) code: 'ECONNREFUSED', errno: 'ECONNREFUSED', syscall: 'connect', address: '::1', port: 50012 }, url: 'localhost:4200' } +0ms

@flotwig
Copy link
Contributor

flotwig commented Jul 12, 2019

@shaharkazaz Thanks for providing this!

You do not have a NO_PROXY environment variable set, correct? It looks like requests for localhost are going through the proxy. echo $NO_PROXY shouldn't return anything.

Also, did you test this with 3.4.0 or another version?

If both of those answers are "yes", can you share the complete debug logs from the session? There's some startup info that is useful to have in there too.

@shaharkazaz
Copy link

@flotwig Happy to help 🙂
I don't have a NO_PROXY environment variable set ( I verified with the echo command).
I tried upgrading to v3.4.0 but I still get the same issue 😞

Is there a way for the logs to be written to a file? there is too much output in these logs

@flotwig
Copy link
Contributor

flotwig commented Jul 12, 2019

For sure, you can use shell redirection:

DEBUG=cypress:* cypress open > log-file.txt 2>&1

@shaharkazaz
Copy link

Ya I figured using shell redirection would probably be the answer 😁
cypress-3.4.0-logs.txt

@shaharkazaz
Copy link

@flotwig did the logs help? any idea what's going on?

@ferparmur
Copy link

I have the same issue. Tried 3.1.5 and 3.4.0 on mac with Chrome and Electron.
image
log-file.txt

@flotwig
Copy link
Contributor

flotwig commented Jul 22, 2019

Hmm, I am curious if the issue is related to launching Cypress for a project listening on port 80.

@fernando-paredes or @shaharkazaz Could you try running your server on a non-standard port? Launch your project on port 3000 for example, then run Cypress with --config baseUrl=http://localhost:3000 and see if the same issue happens.

@shaharkazaz
Copy link

@flotwig my server is running on port 4200

@flotwig
Copy link
Contributor

flotwig commented Jul 22, 2019

Oh, I see that now. :P I did notice that the other two users in the thread are using port 80, so hopefully they can test it out and we can see if it's related to their issue.

Potentially related (same error): #4763

@vijesh-koroth
Copy link

Finally, it worked for me after "plugins->index.js" file is updated with the following arguments

args.push('--disable-gpu')
args.push('--disable-gpu-compositing')
args.push('--disable-gpu-rasterization')
args.push('--config baseUrl=http://localhost:3000')

@jennifer-shehane jennifer-shehane removed the stage: awaiting response Potential fix was proposed; awaiting response label Feb 4, 2020
@jennifer-shehane
Copy link
Member

Closing as resolved. Please open a new issue with a reproducible example if you are encountering an issue similar to the one described in this thread.

@Amrita19900406
Copy link

@vijesh-koroth -- how do we use this in the index.js in plugins?Is this correct. not working for me
module.exports = (on, config) => {

args.push('--disable-gpu')
args.push('--disable-gpu-compositing')
args.push('--disable-gpu-rasterization')
args.push('--config baseUrl=http://localhost:3000')
// on is used to hook into various events Cypress emits
// config is the resolved Cypress config
}

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

No branches or pull requests

7 participants