Cypress: ESOCKETTIMEDOUT error

Created on 21 Nov 2017  路  24Comments  路  Source: cypress-io/cypress

The issue is occurring on my colleague's machine who is offshore (India time). I am submitting this issue on his behalf. Due to the time discrepancy, responses may be slow. However this is a blocking issue for our team since we are trying to convert to using Cypress and TDD as a team thus we need the environment to be working on all machines before beginning our new work. I've googled this issue and tried diagnosing/solving it but so far no luck.

Additional Info (images, stack traces, etc)

Console was cleared
cypress_runner.js:136628 Command:   visit
cypress_runner.js:136628 Error:     CypressError: cy.visit() failed trying to load:

http://localhost:9000/

We attempted to make an http request to this URL but the request failed without a response.

We received this error at the network level:

  > Error: ESOCKETTIMEDOUT

Common situations why this would fail:
  - you don't have internet access
  - you forgot to run / boot your web server
  - your web server isn't accessible
  - you have weird network configuration settings on your computer

The stack trace for this error is:

Error: ESOCKETTIMEDOUT
    at ClientRequest.<anonymous> (C:\Data\Testing\cypress\Cypress\resources\app\packages\server\node_modules\request\request.js:778:19)
    at ClientRequest.g (events.js:286:16)
    at emitNone (events.js:86:13)
    at ClientRequest.emit (events.js:185:7)
    at Socket.emitTimeout (_http_client.js:614:10)
    at Socket.g (events.js:286:16)
    at emitNone (events.js:86:13)
    at Socket.emit (events.js:185:7)
    at Socket._onTimeout (net.js:334:8)
    at tryOnTimeout (timers.js:232:11)
    at Timer.listOnTimeout (timers.js:202:5)


Because this error occurred during a 'before each' hook we are skipping the remaining tests in the current suite: 'Enter BAC Details Wizard Forms'
cypress_runner.js:136628 Snapshot:  The snapshot is missing. Displaying current state of the DOM.

image

  • Operating System: Windows 7
  • Cypress Version: 1.0.3
  • Browser Version: 62

Most helpful comment

For me I had a webserver which failed if it could not find the "Accept-Encoding" header.

Fixed with :

cy.visit(url, {
  headers: {
    "Accept-Encoding": "gzip, deflate"
  }
})

All 24 comments

Does this happen every single time or intermittently?

Can you have them refresh repeatedly, like at least 10 times to see if all 10 times it results in a socket timeout.

Also how long are these errors taking to come back? Instantly or after like 30-60 seconds?

It was every time. Ended up being some edge case issue with the developers host file and corporate settings. It is now fixed.

Hey,
I have this happen intermittently, on a before each that's simply supposed to load the testing page. I'm trying to run cypress on my local dev environment so there's a couple of things going on here like webpack-dev-server and it's live reload WS connection... is this known to be a problem?!
Thanks,
Rui

I eventually see some of these in the console, not sure if it's a problem:

WebSocket connection to 'ws://webpackdevserver:8080/sockjs-node/827/ofpjio5l/websocket' failed: WebSocket is closed before the connection is established.

hey @jennifer-shehane and @brian-mann , i am actually facing the same issues
with cypress 3.1.1 any updates on same

Unfortunately we'll have to close this issue if no reproducible example is provided. Can anyone provide a way to reproduce this - with app and test code?

It's not consistently reproducible but I also encounter this issue as well, on several specs.

image
image

This also happens to me when testing inside our CI environment(codeship basic). There is no problem with local environment, but on CI, ESOCKETTIMEDOUT occurs about half of the time, when visiting an url using cy.visit().

Is this a problem of our CI server(i.e., too slow)? Or, just changing timeout configuration is enough?

(UPDATE) I doubled pageLoadTimeout only on CI and it works as expected. But I'm still not sure this is the right solution to the problem.

I'm getting a similar issue running this locally against a dockerized django app. My cypress service is linked to the app.

cypress:
  volumes:
    - ./app:/app/app
    - ./cypress:/app/cypress
    - ./cypress.json:/app/cypress.json
    - ./wait-for-it.sh:/app/wait-for-it.sh
  build: ./cypress.Dockerfile
  container_name: cypress
  environment:
    - CYPRESS_baseUrl=http://app:8000
  links:
    - app
  command: /app/wait-for-it.sh app:8000 -t 30 -- npx cypress run --spec='./cypress/integration/**'

I get the following errors:

The request we sent was:

Method: GET
URL: http://app:8000/status/

-----------------------------------------------------------

Common situations why this would fail:
  - you don't have internet access
  - you forgot to run / boot your web server
  - your web server isn't accessible
  - you have weird network configuration settings on your computer

The stack trace for this error is:

RequestError: Error: ESOCKETTIMEDOUT
    at new RequestError (/root/.cache/Cypress/3.1.4/Cypress/resources/app/packages/server/node_modules/request-promise-core/lib/errors.js:14:15)
    at Request.plumbing.callback (/root/.cache/Cypress/3.1.4/Cypress/resources/app/packages/server/node_modules/request-promise-core/lib/plumbing.js:87:29)
    at Request.RP$callback [as _callback] (/root/.cache/Cypress/3.1.4/Cypress/resources/app/packages/server/node_modules/request-promise-core/lib/plumbing.js:46:31)
    at self.callback (/root/.cache/Cypress/3.1.4/Cypress/resources/app/packages/server/node_modules/request/request.js:185:22)
    at emitOne (events.js:115:13)
    at Request.emit (events.js:210:7)
    at ClientRequest.<anonymous> (/root/.cache/Cypress/3.1.4/Cypress/resources/app/packages/server/node_modules/request/request.js:819:16)
    at Object.onceWrapper (events.js:314:30)
    at emitNone (events.js:105:13)
    at ClientRequest.emit (events.js:207:7)
    at Socket.emitTimeout (_http_client.js:722:34)
    at Object.onceWrapper (events.js:314:30)
    at emitNone (events.js:105:13)
    at Socket.emit (events.js:207:7)
    at Socket._onTimeout (net.js:402:8)
    at ontimeout (timers.js:469:11)
    at tryOnTimeout (timers.js:304:5)
    at Timer.listOnTimeout (timers.js:264:5)

Ignore me. PEBCAK.

Could this issue be related to this SO question?

https://stackoverflow.com/questions/24320578/node-js-get-request-etimedout-esockettimedout

As per the top answer, would increasing the thread pool size be a potential fix?

Hey @chrispickford, thanks for the suggestion. We already do increase the thread pool.

We'll need a reproducible issue to really track this down. We have fixed several ESOCKETTIMEDOUT issues over recent releases, but may not have gotten them all.

This happens randomly. However the only thing consistent is that it happens on cy.visit() or cy.reload() commands.

@devsh4 Please comment with a reproducible example. We cannot investigate issues that we cannot reproduce.

We are having same issue. Chrome + Circle CI + cy.visit('sub1.domain.com') + cy.visit('sub2.domain.com') + cy.visit('sub1.domain.com') (if 3rd visit takes longer than 3 minutes and 20 seconds, than this error seems to appear).

@chrispickford We did update that environment variable, but the error would still happen every so often. Other StackOverflow threads mention setting the maxSockets property of the request library as an option, but I'm not sure that will help as Cypress runs within the browser. Have you end up finding the solution to the problem?

Today, I'm seeing this error while running Charles Proxy to forward our prod domain to localhost:9002. For me it happens consistently on the same test during the login process... but if I run a single spec instead of all tests, it happens in a different place (after a certain number of requests have been made maybe)?

Screen Shot 2019-08-19 at 4 33 08 PM

Perhaps it is some inconsistency with the proxy in different environments?

If I run it against our prod environment without going through Charles Proxy, there are no issues whatsoever.

I made some progress by bumping up the UV_THREADPOOL_SIZE but not much. I added
process.env.UV_THREADPOOL_SIZE = 64; to the beginning of cypress/support/index.js which consistently allows more tests to run before connections stop working and Cypress ultimately crashes.

Once the timeouts start, it doesn't matter if I stop and restart a spec. As long as the same node process (that started Cypress) is still running, all connections fail.

node v12.8.1
cypress v3.4.1

We've fixed the problem by adding a request header (Connection: "Keep-Alive") to the visit command.

For me I had a webserver which failed if it could not find the "Accept-Encoding" header.

Fixed with :

cy.visit(url, {
  headers: {
    "Accept-Encoding": "gzip, deflate"
  }
})

For me I had a webserver which failed if it could not find the "Accept-Encoding" header.

Fixed with :

                    cy.visit(url, {
                        headers: {
                            "Accept-Encoding": "gzip, deflate"
                        }
                    })

Thanks @thomasleveil for giving solution.. It really worked for me :)

We've fixed the problem by adding a request header (Connection: "Keep-Alive") to the visit command.

Nothing for me still facing the issue cv 4.0.2

This issue is closed.

If you're experiencing a bug similar to this in Cypress, please open a new issue with a fully reproducible example that we can run. There may be a specific edge case with the issue that we need more detail to fix.

For me I had a webserver which failed if it could not find the "Accept-Encoding" header.

Fixed with :

cy.visit(url, {
  headers: {
    "Accept-Encoding": "gzip, deflate"
  }
})

Thank you, @thomasleveil ! This was driving me crazy and your suggestion worked like a charm.

I spoke too soon. This worked for me locally, but when I ran the same test in a CodeBuild job, I got the ESOCKETTIMEDOUT error again, despite having "Accept-Encoding": "gzip, deflate" in the headers.

Was this page helpful?
0 / 5 - 0 ratings