Open otalandim opened 4 years ago
I see that you are using an older version of Cypress. Please update to the current version of Cypress and let us know if this is still happening for you. Your issue may have already been fixed. Thanks!
Hi @jennifer-shehane and @otalandim,
I had the same issue, locally all is working fine but on GitLab CI, one or two tests always fail with the above mentioned error message: Error: ESOCKETTIMEDOUT
.
Currently, I workaround this by using cypress-plugin-retries
, so when the error happens, the test gets retried.
Unfortunately I can't tell you how to reprocedure the whole thing, because it very sporadically always hits different tests. But basically it happens at cy.visit()
. Previously I used cypress@3.8.4
and never got this error before. I read more about it in GitHub issues and perhaps this is another "workaround": https://github.com/cypress-io/cypress/issues/350#issuecomment-267704772; but I did not test it.
Similar tickets: #6547, #5975 Used Cypress Version: 4.4.1
@jennifer-shehane, @otalandim, @matzeeable - I'm seeing something similar. I'm unable to visit a certain URL (www.tesla.com) when tests are running in CircleCI (also tried BitBucket) - I receive the infamous ESOCKETTIMEDOUT
error. It works fine if I run the tests via Test Runner or CLI (headless or headed). I tried increasing the pageLoadTimeout but that didn't work. I also tried both Electron and Chrome with same results. I also did confirm that replacing cy.visit with cy.request yields 200 response.
I'm using Cypress 4.6.0
This is my basic config.yml (CircleCI):
version: 2.1
orbs:
cypress: cypress-io/cypress@1.23.0
workflows:
build:
jobs:
- cypress/run
And a simple test that will run fine in Test Runner/CLI, but fail on Circle CI/BitBucket:
it.only('Test Tesla Link', () => {
cy.visit('https://www.tesla.com', {
headers: {
"Accept-Encoding": "gzip, deflate, br"
}
})
I'm having the same issue using CircleCI and that orb version: cypress-io/cypress@1.25.0
I'm using Chrome for the browser.
I can recreate this using our circleci orb with the test code below.
cypress open
or cypress run
locally. My failing PR here: https://github.com/cypress-io/circleci-orb-example/pull/11 Run with DEBUG logs: https://circleci.com/gh/cypress-io/circleci-orb-example/27
spec.js
it('Test Tesla Link', () => {
cy.visit('https://www.tesla.com')
})
circle.yml
version: 2.1
orbs:
cypress: cypress-io/cypress@1
workflows:
build:
jobs:
- cypress/run:
name: Debug with Cypress logs
debug: 'cypress:*'
This issue seems to happen even inside of a Node.js REPL:
const rp = require('request-promise')
console.time('loading')
rp('https://www.tesla.com', { timeout: 15000 })
.then(() => console.timeEnd('loading'))
.catch((err) => console.error(err))
This will fail after 15s with ESOCKETTIMEDOUT (tested in Node 12.8.1).
My first idea was that www.tesla.com
never finishes sending /
, that it continually streams data... but that does not appear to be the case, loading the site in a regular web browser, the request ends once the content is served. So I'm not sure what the root cause is of this problem. But if the ESOCKETTIMEDOUT can be fixed in Node, that should fix it in Cypress as well.
Also some previous investigation into bestbuy.com and staples.com issuing an ESOCKETTIMEDOUT - https://github.com/cypress-io/cypress/issues/2778#issuecomment-516010247
There was a comment in the request library mentioning why this ESOCKETTIMEDOUT may be happening with the request library. https://github.com/request/request/issues/2738#issuecomment-369324868
I think bestbuy.com may be blocking the request due to the default headers being sent from request. If the request is made with the same headers that the axios request is sending, it does not time out:
const request = require('request');
const axios = require('axios');
const url = 'http://www.bestbuy.com/';
request({
url: url,
timeout: 5000,
headers: {
"Accept": "application/json, text/plain, */*",
"User-Agent": "axios/0.18.0"
}
}, (error, response, body) => {
if (!error)
console.log(`request got ${response.statusCode}`);
else
console.error(`request got an error`, error);
});
axios.get(url).then((ret) => {
console.log(`Axios got ${ret.status}`);
});
Any update on this one @jennifer-shehane. I am getting the same when using Travis CI. I implemented Contrast (security and vulnerabilities agent). Runs local, times-out in Travis regardless of all the attempts to the contrary following all the issues here. Thanks.
We're seeing the exact same problem after adding more tests to our test suite and they're only failing when running via headless chrome on GitLab. We haven't found the root cause or a solution yet. Cypress: 4.12.1 / Image: cypress/browsers:node12.16.2-chrome81-ff75
If we could figure out why Node.js can't load these websites, we could fix the issue. It's not exactly a Cypress issue, it seems to be reproducible with just regular Node HTTP requests: https://github.com/cypress-io/cypress/issues/7062#issuecomment-664776610
I can not reproduce the failure using the given example. Also Cypress forked the request library at @cypress/request
, so even if the problem originated in the request
library, it's certainly present in the fork as well.
Update (08/13): We were able to reproduce the problem using only @cypress/request
. The problem only happens in our Docker/GitLab-Setup and it also happens with axios
. After ~700 requests, we seem to run into some kind of limit. We're still investigating.
We are having this same issue in our ci/cd pipeline when cypress runs in it. does not happen locally. only in the GitLab pipeline. It is intermittent too : sometimes passes and some times it just fails.
We are having this same issue in our ci/cd pipeline when cypress runs in it. does not happen locally. only in the GitLab pipeline. It is intermittent too : sometimes passes and some times it just fails.
Same problem here!
We were close to cancel our move to Cypress, because at some point while adding more and more tests, we experienced more and more failing tests. Interestingly it were always the last few tests that were failing, regardless of which tests ran last.
We are running Cypress in a Docker container on GitLab and we finally solved this problem for us by splitting the docker-compose startup and actually running the tests into separate commands. Here's the change to our gitlab-ci.yml
:
Before:
acceptance_tests:
script:
- docker-compose run --use-aliases acceptance-tests /opt/project/bin/run-tests
After:
acceptance_tests:
script:
- docker-compose up -d nginx rails-app frontend postgres && docker-compose run --use-aliases acceptance-tests /opt/project/bin/run-tests
🤷
+1
getting the same issue via github
reverting to use cypress version 5.1.0 fixes the issue for me
i installed cypress in laravel with the following guide https://github.com/laracasts/cypress after running the command php artisan cypress:boilerplate cypress no longer works @jennifer-shehane
any test application always gives me the following error:
TEST BODY
1
visit
/
CypressError
cy.visit() failed trying to load:
http://my-app.test/
The response we received from your web server was:
> 500: Server Error
This was considered a failure because the status code was not 2xx.
If you do not want status codes to cause failures pass the option: failOnStatusCode: false
cypress/integration/ex_spec.js:2:5
1 | it('works',() =>{
> 2 | cy.visit('/').contains('Enviroment:Acceptance');
| ^
3 | })
We are experiencing the same issue as https://github.com/cypress-io/cypress/issues/5975. Localhost requests all throw ESOCKETTIMEDOUT error. The error happens every time.
I tried @rubiii and @hslee16 approaches but we still encounter the error.
For me, the problem was how I started the webserver. I'm using start-server-and-test
and had to change start-server http://localhost:8080
to start-server http-get://localhost:8080
(see Note for webpack-dev-server users).
Hi, everyone, some news?
We had the same problem when adding a new test file, the first test file started failing only one test:
We use github-actions.
1) Auth
should redirect private page to /login:
CypressError: `cy.visit()` failed trying to load:
http://localhost:3000/
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
at http://localhost:3000/__cypress/runner/cypress_runner.js:157710:23
at visitFailedByErr (http://localhost:3000/__cypress/runner/cypress_runner.js:157065:12)
at http://localhost:3000/__cypress/runner/cypress_runner.js:157709:11
at tryCatcher (http://localhost:3000/__cypress/runner/cypress_runner.js:10325:23)
at Promise._settlePromiseFromHandler (http://localhost:3000/__cypress/runner/cypress_runner.js:8260:31)
at Promise._settlePromise (http://localhost:3000/__cypress/runner/cypress_runner.js:8317:18)
at Promise._settlePromise0 (http://localhost:3000/__cypress/runner/cypress_runner.js:8362:10)
at Promise._settlePromises (http://localhost:3000/__cypress/runner/cypress_runner.js:8438:18)
at _drainQueueStep (http://localhost:3000/__cypress/runner/cypress_runner.js:5032:12)
at _drainQueue (http://localhost:3000/__cypress/runner/cypress_runner.js:5025:9)
at Async.../../node_modules/bluebird/js/release/async.js.Async._drainQueues (http://localhost:3000/__cypress/runner/cypress_runner.js:5041:5)
at Async.drainQueues (http://localhost:3000/__cypress/runner/cypress_runner.js:4911:14)
From Your Spec Code:
at Context.eval (http://localhost:3000/__cypress/tests?p=cypress/integration/auth.spec.ts:103:12)
From Node.js Internals:
Error: ESOCKETTIMEDOUT
at ClientRequest.<anonymous> (/home/runner/.cache/Cypress/5.3.0/Cypress/resources/app/packages/server/node_modules/@cypress/request/request.js:816:19)
at Object.onceWrapper (events.js:312:28)
at ClientRequest.emit (events.js:223:5)
at Socket.emitRequestTimeout (_http_client.js:690:9)
at Object.onceWrapper (events.js:312:28)
at Socket.emit (events.js:223:5)
at Socket._onTimeout (net.js:474:8)
at listOnTimeout (internal/timers.js:531:17)
at processTimers (internal/timers.js:475:7)
Update, I remove these packages from the project and all tests return to pass:
"@material-ui/core": "^4.11.0",
"@material-ui/icons": "^4.9.1",
Hello everyone. Any updates on this issue, still opened since April 18? or any resolution process? Thanks
Also some previous investigation into bestbuy.com and staples.com issuing an ESOCKETTIMEDOUT - #2778 (comment)
There was a comment in the request library mentioning why this ESOCKETTIMEDOUT may be happening with the request library. request/request#2738 (comment)
I think bestbuy.com may be blocking the request due to the default headers being sent from request. If the request is made with the same headers that the axios request is sending, it does not time out:
const request = require('request'); const axios = require('axios'); const url = 'http://www.bestbuy.com/'; request({ url: url, timeout: 5000, headers: { "Accept": "application/json, text/plain, */*", "User-Agent": "axios/0.18.0" } }, (error, response, body) => { if (!error) console.log(`request got ${response.statusCode}`); else console.error(`request got an error`, error); }); axios.get(url).then((ret) => { console.log(`Axios got ${ret.status}`); });
The above clued me in on how to solve this.
cy.visit({
url: 'www.bestbuy.com',
headers: {
"Accept": "application/json, text/plain, */*",
"User-Agent": "axios/0.18.0"
}
});
Hopefully this is helpful to someone.
I had a similar problem running cypress against a website from a locally running docker container. For me, a call to cy.visit(...) inside a before()-hook failed if the server took longer than 30 seconds to respond. According to the documentation, pageLoadTimeout is responsible for cy.visit(...), but i fixed it using responseTimeout. Playing around with different values of these two timeouts i figured out that the ESOCKETTIMEDOUT occurs if the server does not respond in during responseTimeout although pageLoadTimeout was set high enough when using this in a before/beforeEach-hook.
@jennifer-shehane is this intended? https://docs.cypress.io/guides/references/configuration.html#Timeouts says otherwise.
I threw together a simple express server that waited before sending the response to test this, because cypress itself, the request package of cypress and chrome in headless mode all took about 45 sec to access the page, while normal chrome or curl are usually faster. The set timeout was the highest i could reach without it being rounded up to 30 and thus causing the error.
const express = require("express");
const app = express();
const port = 3000;
app.get("/", (req, res) => {
res.setTimeout(
29980, () => {
res.send("ok");
});
});
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`);
});
@theoshallburn Thanks for the repro and the lead on the responseTimeout
.
Increasing the responseTimeout
doesn't fix the original issue with the Tesla and BestBuy website - there's something preventing that website from loading altogether in Cypress so it eventually timesout.
node app.js
cypress open
package.json
{
"devDependencies": {
"cypress": "6.2.0",
"express": "4.17.1"
}
}
app.js
const express = require('express')
const app = express()
app.get('/', (req, res) => {
res.setTimeout(
// setting this < 30000 will pass
// setting this to 30000 will throw ESOCKETTIMEDOUT
30000, () => {
res.send('ok')
})
})
app.listen(port, () => {
console.log(`Example app listening at http://localhost:3000`)
})
cypress/integration/spec.js
it('visit', () => {
// this `pageLoadTimeout` does not prevent ESOCKETTIMEDOUT
// cy.visit('http://localhost:3000', { pageLoadTimeout: 80000 })
// this `responseTimeout` does prevent ESOCKETTIMEDOUT
cy.visit('http://localhost:3000', { responseTimeout: 31000 })
cy.contains('ok')
})
responseTimeout
increaseresponseTimeout: 31000
If your app takes > 30 seconds to load and does eventually load, increase the responseTimeout
passed to cy.visit()
. I'll have to check and see why this is.
, { responseTimeout: 31000 }
I tried this but still having the same issue. CI is still failing.
We are having this same issue in our ci/cd pipeline when cypress runs in it. does not happen locally. only in the GitLab pipeline. It is intermittent too : sometimes passes and some times it just fails.
same scenario here
Hi team, just want to report the issue here too. Using github cypress action.
Error: ESOCKETTIMEDOUT
Because this error occurred during a `before all` hook we are skipping the remaining tests in the current suite: `Staff profile page `
at http://0.0.0.0:5051/__cypress/runner/cypress_runner.js:157807:23
at visitFailedByErr (http://0.0.0.0:5051/__cypress/runner/cypress_runner.js:157162:12)
at http://0.0.0.0:5051/__cypress/runner/cypress_runner.js:157806:11
at tryCatcher (http://0.0.0.0:5051/__cypress/runner/cypress_runner.js:10325:23)
at Promise._settlePromiseFromHandler (http://0.0.0.0:5051/__cypress/runner/cypress_runner.js:8260:31)
at Promise._settlePromise (http://0.0.0.0:5051/__cypress/runner/cypress_runner.js:8317:18)
at Promise._settlePromise0 (http://0.0.0.0:5051/__cypress/runner/cypress_runner.js:8362:10)
at Promise._settlePromises (http://0.0.0.0:5051/__cypress/runner/cypress_runner.js:8438:18)
at _drainQueueStep (http://0.0.0.0:5051/__cypress/runner/cypress_runner.js:5032:12)
at _drainQueue (http://0.0.0.0:5051/__cypress/runner/cypress_runner.js:5025:9)
at Async.../../node_modules/bluebird/js/release/async.js.Async._drainQueues (http://0.0.0.0:5051/__cypress/runner/cypress_runner.js:5041:5)
at Async.drainQueues (http://0.0.0.0:5051/__cypress/runner/cypress_runner.js:4911:14)
From Your Spec Code:
at Context.eval (http://0.0.0.0:5051/__cypress/tests?p=packages/staff/integration-test/integration/examples/staffProfile/edgeCases/supportReachLimit.spec.ts:16956:16)
No complicated request
cy.loadData(staffProfileMockApi).then(() => {
cy.visit('http://0.0.0.0:5051/')
})
- name: Cypress test
uses: cypress.io/github-action@v2
with:
start: yarn start:server
wait-on: 'http://0.0.0.0:5051'
I have tried: 1. downgrade cypress to 5.1 2.make requestTimeout
to 30s 3. Add header
in request. But no luck.
All tests pass in local env.
I had the same problem, it was a server issue in my case. Just before to the frontend server, Cypress gets started. The following points need to be confirmed:
yarn start
command takes some time to start the server so that you can't run the cypress immediately after the start command.Same here:
https://github.com/estefafdez/cypress-template/runs/1682540584
Any update on this issue? Thanks team!
Same here:
https://github.com/estefafdez/cypress-template/runs/1682540584
Any update on this issue? Thanks team!
How are you setting up your env?
@DigneshGujarathi on a configuration file, you can have a look at the code here: https://github.com/estefafdez/cypress-template/blob/main/cypress/config/qa.json
@DigneshGujarathi on a configuration file, you can have a look at the code here: https://github.com/estefafdez/cypress-template/blob/main/cypress/config/qa.json
Did you try https://github.com/cypress-io/cypress/issues/2938#issuecomment-549565158?
@DigneshGujarathi on a configuration file, you can have a look at the code here: https://github.com/estefafdez/cypress-template/blob/main/cypress/config/qa.json
Did you try #2938 (comment)?
Yes, I did, but it's not working either. Thanks for sharing that :)
Thanks @jennifer-shehane , Increasing responseTimeout
works for me.
If you're running the Angular dev-server with Cypress, removing optimization
and buildOptimizer
from your build options in angular.json
might help.
Surprisingly, removing both optimization
and buildOptimizer
from angular.json
seems to have ESOCKETTIMEDOUT
error solved in my GitLab CI. Btw, I am serving Angular app in CI environment.
Surprisingly, removing both
optimization
andbuildOptimizer
fromangular.json
seems to haveESOCKETTIMEDOUT
error solved in my GitLab CI. Btw, I am serving Angular app in CI environment.
Yeah, the issue is probably related to tree-shaking. Glad it helped!
reverting to use cypress version 5.1.0 fixes the issue for me
Yes. And for me. I use github actions. But first test failed. I fixed it with cy.wait(31000) But looks like real problem in waiting dev server May be this can help. (Also without downgrade version)
with wait-on: 'http://localhost:3000' wait-on-timeout: 120
Thanks @theoshallburn and @jennifer-shehane . Increasing the cy.visit responseTimeout seemed to work for me, too.
But one of our developers pointed out that responseTimeout is not a parameter documented for cy.visit. Is this feature undocumented because we shouldn't rely on it, or is this just an oversight?
I was facing same issue while testing my angular project at "localhost:4200", i resolved by placing "http://localhost:4200" instead of "https://localhost:4200". I wasn't aware that "s" will waste so much time of me. 😄
Faced the issue with BitBucker pipeline. The problem seems to be in dev server. It haven't been started yet, but Cypress tried to visit it. For me worked
before(() => {
cy.wait(20000);
});
Of course the solution is not very good, but I haven't found better one.
Take a look at the start-server-and-test NPM module
Sent from my iPhone
On Jun 13, 2021, at 10:21, Kolotushkin Maxim @.***> wrote:
Faced the issue with BitBucker pipeline. The problem seems to be in dev server. It haven't been started yet, but Cypress tried to visit it. For me worked
before(() => { cy.wait(20000); }); Of course the solution is not very good, but I haven't found better one.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.
Take a look at the start-server-and-test NPM module …
That worked for me, thanks a lot!
@jennifer-shehane I'm also getting the same error on cy.visit() & cy.request() timed out. Specifically, I started getting these issues when I added backend test coverage for e2e cypress tests. When added only frontend test coverage, it worked well. I'm finding this issue while running tests on GitHub CI server. I tried solutions given in the above discussion, but nothing worked.
Cy.visit() error:
"before each" hook for "availabilities Test":
CypressError: `cy.visit()` failed trying to load:
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: connect ECONNREFUSED 127.0.0.1:3000
Common situations why this would fail:
cy.request()
failed trying to load:http://localhost:3000/__coverage__
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: connect ECONNREFUSED 127.0.0.1:3000
The request we sent was:
Method: GET URL: http://localhost:3000/__coverage__
Common situations why this would fail:
Hello there, we are having the same issue on CircleCi. I run: 315 jobs and 217 of them fail due to this. To increase the timeout is not a fix for us, it will make all the test last longer and will consume all our credit on CircleCi. We already increase the resources to X-Large just for Cypress tests. I updated to the latest version hoping that this will somehow fix it but nope.
@jennifer-shehane Hello , we are also getting the same issue. We created total 56 specs, always we are getting the error for the first two specs. We are not getting error, if we close and rerun the scripts for the second time. Let me know if you need more information.
Cypress package version: 8.1.0 Cypress binary version: 8.1.0 Electron version: 12.0.0-beta.14 Bundled Node version:
I am having the same issue... :( Is there no resolution after a year?
@jennifer-shehane , we really need a solution for this. We are unable to proceed further.
Hello, I have regularly experienced this issue with my Production host.
for the Stage - all works as expected and tests successfully passed. When I'm running tests from a local machine - the same - all fine.
but when the tests are executed with GitLab CI on the Production host - 50% time it just fails with unable to open the requested URL.
Current behavior:
Desired behavior:
Does not start testing on gitlab, but on local machine it does works
Test code to reproduce
Starts the tests in gitlab
Versions
Cypress: 4.2.0 Image: cypress/base