Testcafe fails on starting
What is your Scenario?
We have a set of tests which executes every 30 mins 24/7
What is the Current behavior?
We have around 50 executions per day, but 3-6 executions might be randomly failed. The test code is exactly same.
The "concurrency" and "quarantineMode" options from the configuration file will be ignored. ERROR Cannot establish one or more browser connections. 1 of 2 browser connections have not been established:
- chrome:headless
Hints:
- Increase the Browser Initialization Timeout if its value is too low (currently: 2 minutes for all browsers). The timeout determines how long TestCafe waits for browsers to be ready.
- The error can also be caused by network issues or remote device failure. Make sure that your network connection is stable and you can reach the remote device.
Type "testcafe -h" for help.
There is no logs, screenshots and even before hook is not started. How can we determine what happens? Or let me know what can we provide additionally. Code is not relevant the the code itself works fine, sometimes something goes wrong with testcase itself.
Tests are running in GH hosted agents with concurrency 2. browserInitTimeout is already huge, no issue with app under test.
We also have similar configuration of executions with playwright, no similar issues there. So I don't think the reason in GH hosted agent.
What is the Expected behavior?
Should work as other ~45 executions
What is the public URL of the test page? (attach your complete example)
N/A
What is your TestCafe test code?
N/A
Your complete configuration file
module.exports = { screenshots: { path: "./artifacts/screenshots", takeOnFails: false, pathPattern: "${DATE}${TIME}/${TEST}/${FILE_INDEX}${QUARANTINE_ATTEMPT}.png", thumbnails: false }, disableMultipleWindows: true, browsers: "chrome:headless", concurrency: 2, skipJsErrors: true, browserInitTimeout: 120000, pageLoadTimeout: 60000, pageRequestTimeout: 65000, selectorTimeout: 20000, testExecutionTimeout: 900000, quarantineMode: false, disableNativeAutomation: false, testResults, }
Your complete test report
No response
Screenshots
No response
Steps to Reproduce
N/A
TestCafe version
3.6.0
Node.js version
v18
Command-line arguments
yarn testcafe
Browser name(s) and version(s)
No response
Platform(s) and version(s)
No response
Other
No response
Hello @vasilyevi,
Without accurately reproducing the issue, it's difficult to determine what goes wrong.
Could you please try running TestCafe with a debug log? To enable the debug log, you can do the following:
set DEBUG=testcafe:*,hammerhead:*
testcafe chrome index.js 2> testcafe.log
Before running TestCafe, set the DEBUG environment variable as shown above. Then, run TestCafe and redirect the output to a file.
Please refer to the following help topic for details: https://testcafe.io/documentation/402636/faq/general-info#related-questions.
@PavelMor25
2024-10-09T08:17:02.833Z testcafe:cli [ '/opt/hostedtoolcache/node/20.17.0/x64/bin/node', '/home/runner/work/tests/node_modules/gherkin-testcafe/main.js', '--param-type-registry-file', './guide-to-common/features/steps/transformers.js', '--src', './some.feature', './some.js', 2024-10-09T08:18:54.948Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.222 interception-job-210.0 response http://localhost:38567/browser/status/EsiCUd6 2024-10-09T08:18:55.952Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.223 interception-job-211.0 request http://localhost:38567/browser/init-script/EsiCUd6 2024-10-09T08:18:55.953Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.224 interception-job-212.0 request http://localhost:38567/browser/status/EsiCUd6 2024-10-09T08:18:55.956Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.223 interception-job-211.0 response http://localhost:38567/browser/init-script/EsiCUd6 2024-10-09T08:18:55.958Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.224 interception-job-212.0 response http://localhost:38567/browser/status/EsiCUd6 2024-10-09T08:18:56.021Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.225 interception-job-213.0 request http://localhost:38567/browser/heartbeat/EsiCUd6 2024-10-09T08:18:56.024Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.225 interception-job-213.0 response http://localhost:38567/browser/heartbeat/EsiCUd6 2024-10-09T08:18:56.962Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.226 interception-job-214.0 request http://localhost:38567/browser/init-script/EsiCUd6 2024-10-09T08:18:56.963Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.227 interception-job-215.0 request http://localhost:38567/browser/status/EsiCUd6 2024-10-09T08:18:56.965Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.226 interception-job-214.0 response http://localhost:38567/browser/init-script/EsiCUd6 2024-10-09T08:18:56.968Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.227 interception-job-215.0 response http://localhost:38567/browser/status/EsiCUd6 2024-10-09T08:18:57.972Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.228 interception-job-216.0 request http://localhost:38567/browser/init-script/EsiCUd6 2024-10-09T08:18:57.973Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.229 interception-job-217.0 request http://localhost:38567/browser/status/EsiCUd6 2024-10-09T08:18:57.977Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.228 interception-job-216.0 response http://localhost:38567/browser/init-script/EsiCUd6 2024-10-09T08:18:57.979Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.229 interception-job-217.0 response http://localhost:38567/browser/status/EsiCUd6 2024-10-09T08:18:58.014Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.230 interception-job-218.0 request http://localhost:38567/browser/heartbeat/EsiCUd6 2024-10-09T08:18:58.017Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.230 interception-job-218.0 response http://localhost:38567/browser/heartbeat/EsiCUd6 2024-10-09T08:18:58.993Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.231 interception-job-219.0 request http://localhost:38567/browser/init-script/EsiCUd6 2024-10-09T08:18:58.994Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.232 interception-job-220.0 request http://localhost:38567/browser/status/EsiCUd6 2024-10-09T08:18:58.998Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.231 interception-job-219.0 response http://localhost:38567/browser/init-script/EsiCUd6 2024-10-09T08:18:59.000Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.232 interception-job-220.0 response http://localhost:38567/browser/status/EsiCUd6 2024-10-09T08:19:00.013Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.233 interception-job-221.0 request http://localhost:38567/browser/init-script/EsiCUd6 2024-10-09T08:19:00.014Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.234 interception-job-222.0 request http://localhost:38567/browser/status/EsiCUd6 2024-10-09T08:19:00.015Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.235 interception-job-223.0 request http://localhost:38567/browser/heartbeat/EsiCUd6 2024-10-09T08:19:00.018Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.233 interception-job-221.0 response http://localhost:38567/browser/init-script/EsiCUd6 2024-10-09T08:19:00.020Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.234 interception-job-222.0 response http://localhost:38567/browser/status/EsiCUd6 2024-10-09T08:19:00.021Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.235 interception-job-223.0 response http://localhost:38567/browser/heartbeat/EsiCUd6 2024-10-09T08:19:01.032Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.236 interception-job-224.0 request http://localhost:38567/browser/init-script/EsiCUd6 2024-10-09T08:19:01.032Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.237 interception-job-225.0 request http://localhost:38567/browser/status/EsiCUd6 2024-10-09T08:19:01.035Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.236 interception-job-224.0 response http://localhost:38567/browser/init-script/EsiCUd6 2024-10-09T08:19:01.037Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.237 interception-job-225.0 response http://localhost:38567/browser/status/EsiCUd6 2024-10-09T08:19:02.022Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.238 interception-job-226.0 request http://localhost:38567/browser/heartbeat/EsiCUd6 2024-10-09T08:19:02.024Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.238 interception-job-226.0 response http://localhost:38567/browser/heartbeat/EsiCUd6 2024-10-09T08:19:02.040Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.239 interception-job-227.0 request http://localhost:38567/browser/init-script/EsiCUd6 2024-10-09T08:19:02.042Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.240 interception-job-228.0 request http://localhost:38567/browser/status/EsiCUd6 2024-10-09T08:19:02.043Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.239 interception-job-227.0 response http://localhost:38567/browser/init-script/EsiCUd6 2024-10-09T08:19:02.045Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.240 interception-job-228.0 response http://localhost:38567/browser/status/EsiCUd6 2024-10-09T08:19:03.047Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.241 interception-job-229.0 request http://localhost:38567/browser/init-script/EsiCUd6 2024-10-09T08:19:03.049Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.242 interception-job-230.0 request http://localhost:38567/browser/status/EsiCUd6 2024-10-09T08:19:03.052Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.241 interception-job-229.0 response http://localhost:38567/browser/init-script/EsiCUd6 2024-10-09T08:19:03.054Z testcafe:native-automation:request-pipeline:service-request requestPaused 2267.242 interception-job-230.0 response http://localhost:38567/browser/status/EsiCUd6 2024-10-09T08:19:03.130Z testcafe:browser:connection:plS5Naj status changed to 'closing' 2024-10-09T08:19:03.130Z testcafe:browser:connection:EsiCUd6 status changed to 'closing' 2024-10-09T08:19:03.133Z testcafe:browser:connection:plS5Naj TypeError: Cannot read properties of undefined (reading 'config') at BrowserProviderPluginHost.isHeadlessBrowser (/home/runner/work/tests/node_modules/testcafe/src/browser/provider/built-in/dedicated/base.js:69:51) at BrowserProvider.canUseDefaultWindowActions (/home/runner/work/tests/node_modules/testcafe/src/browser/provider/index.ts:266:53) at BrowserProvider.closeBrowser (/home/runner/work/tests/node_modules/testcafe/src/browser/provider/index.ts:336:44) at BrowserConnection._closeBrowser (/home/runner/work/tests/node_modules/testcafe/src/browser/connection/index.ts:304:13) at BrowserConnection.close (/home/runner/work/tests/node_modules/testcafe/src/browser/connection/index.ts:513:9) at Function._closeConnection (/home/runner/work/tests/node_modules/testcafe/src/runner/browser-set.ts:58:9) 2024-10-09T08:19:03.134Z testcafe:browser:connection:plS5Naj status changed to 'closed' 2024-10-09T08:19:03.137Z testcafe:native-automation nativeAutomation disposed 2024-10-09T08:19:05.248Z testcafe:browser:provider:chrome browser closed EsiCUd6 2024-10-09T08:19:05.248Z testcafe:browser:connection:EsiCUd6 status changed to 'closed' ERROR Cannot establish one or more browser connections. 1 of 2 browser connections have not been established:
- chrome:headless
Hints:
- Increase the Browser Initialization Timeout if its value is too low (currently: 2 minutes for all browsers). The timeout determines how long TestCafe waits for browsers to be ready.
- The error can also be caused by network issues or remote device failure. Make sure that your network connection is stable and you can reach the remote device.
Type "testcafe -h" for help.
Hello @vasilyevi,
Try to run Chrome with --disable-search-engine-choice-screen arguments.
// configuration file
{
// ...
browsers: "chrome:headless --disable-search-engine-choice-screen",
// ...
}
It does not help
Hello,
We have released testcafe 3.7.0-rc.1, which might address this issue.
Please test it and let us know your results.
Not OP, but I had this same issue and 3.7.0 fixed it
Also not the OP, but for us this issue is introduced since 3.7.0. We run the testcafe docker (chromium:headless) in the pipeline. It does not occur with every test job, but randomly (retry solves it).
This issue was automatically closed because there was no response to our request for more information from the original author. Currently, we don't have enough information to take action. Please reach out to us if you find the necessary information and are able to share it. We are also eager to know if you resolved the issue on your own and can share your findings with everyone.
Also not the OP, but for us this issue is introduced since 3.7.0. We run the testcafe docker (chromium:headless) in the pipeline. It does not occur with every test job, but randomly (retry solves it).
Still applicable for us with testcafe 3.7.0 and 3.7.1 :
We had to revert to testcafe 3.6.2 to have successful pipelines again. Is it possible to re-open the issue?
Hello, I believe we fixed this issue as it was also in our internal backlog. We have not yet released this fix. Hopefully, we will add it to our next release. Please stay tuned.
@Bayheck I am still experiencing this issue on the latest version. Do you have an idea as to when it may get released?
Hello, by 'latest', do you mean TestCafe version 3.7.2?
If so, we need a simple and reliable start-to-end example, preferably a repository. Please ensure the repository and test are as minimal as possible, with clear instructions on how to reproduce the issue. The repository should contain all necessary information and files to reproduce the issue so that any user can follow your instructions. Something like this:
Do we have any answers to this -
2025-05-09T09:45:54.895Z testcafe:browser:connection:l1h8jkG status changed to 'ready' 2025-05-09T09:45:54.897Z testcafe:browser:connection:TgECtIu status changed to 'ready' 2025-05-09T09:45:54.900Z testcafe:browser:connection:wxZpikt status changed to 'ready' 2025-05-09T09:45:54.902Z testcafe:browser:connection:l-p8ZsK status changed to 'ready' 2025-05-09T09:45:54.905Z testcafe:browser:connection:QVQ11bP status changed to 'ready' 2025-05-09T09:45:54.907Z testcafe:browser:connection:KfJX_XJ status changed to 'ready' 2025-05-09T09:45:54.909Z testcafe:browser:connection:TROGdAY status changed to 'ready' 2025-05-09T09:45:54.929Z testcafe:browser:connection:Gz8Xlw9 status changed to 'ready' 2025-05-09T09:45:54.936Z testcafe:browser:connection:f9lCb0h status changed to 'ready' 2025-05-09T09:45:54.963Z testcafe:browser:connection:HyrueS7 status changed to 'ready' 2025-05-09T09:45:54.989Z testcafe:browser:connection:p0IyWG1 status changed to 'ready' 2025-05-09T09:45:55.569Z testcafe:browser:connection:dOFzPdE status changed to 'opened' 2025-05-09T09:45:55.580Z testcafe:browser:connection:KfJX_XJ status changed to 'opened' 2025-05-09T09:45:55.587Z testcafe:browser:connection:f9lCb0h status changed to 'opened' 2025-05-09T09:45:55.599Z testcafe:browser:connection:l-p8ZsK status changed to 'opened' 2025-05-09T09:45:55.617Z testcafe:browser:connection:QVQ11bP status changed to 'opened' 2025-05-09T09:45:55.619Z testcafe:browser:connection:l1h8jkG status changed to 'opened' 2025-05-09T09:45:55.637Z testcafe:browser:connection:TROGdAY status changed to 'opened' 2025-05-09T09:45:55.645Z testcafe:browser:connection:icVv99X status changed to 'opened' 2025-05-09T09:45:55.657Z testcafe:browser:connection:Gz8Xlw9 status changed to 'opened' 2025-05-09T09:45:55.659Z testcafe:browser:connection:p0IyWG1 status changed to 'opened' 2025-05-09T09:45:55.665Z testcafe:browser:connection:HyrueS7 status changed to 'opened' 2025-05-09T09:45:55.667Z testcafe:browser:connection:7Bk8lap status changed to 'opened' 2025-05-09T09:45:55.688Z testcafe:browser:connection:wxZpikt status changed to 'opened' 2025-05-09T09:45:55.832Z testcafe:browser:connection:TgECtIu status changed to 'opened' 2025-05-09T09:50:43.685Z testcafe:browser:connection:l1h8jkG status changed to 'closing' 2025-05-09T09:50:43.685Z testcafe:browser:connection:wxZpikt status changed to 'closing' 2025-05-09T09:50:43.685Z testcafe:browser:connection:icVv99X status changed to 'closing' 2025-05-09T09:50:43.685Z testcafe:browser:connection:QVQ11bP status changed to 'closing' 2025-05-09T09:50:43.685Z testcafe:browser:connection:f9lCb0h status changed to 'closing' 2025-05-09T09:50:43.685Z testcafe:browser:connection:KfJX_XJ status changed to 'closing' 2025-05-09T09:50:43.685Z testcafe:browser:connection:TROGdAY status changed to 'closing' 2025-05-09T09:50:43.685Z testcafe:browser:connection:dOFzPdE status changed to 'closing' 2025-05-09T09:50:43.685Z testcafe:browser:connection:zBob4cE status changed to 'closing' 2025-05-09T09:50:43.685Z testcafe:browser:connection:TgECtIu status changed to 'closing' 2025-05-09T09:50:43.685Z testcafe:browser:connection:Gz8Xlw9 status changed to 'closing' 2025-05-09T09:50:43.685Z testcafe:browser:connection:l-p8ZsK status changed to 'closing' 2025-05-09T09:50:43.685Z testcafe:browser:connection:p0IyWG1 status changed to 'closing' 2025-05-09T09:50:43.685Z testcafe:browser:connection:HyrueS7 status changed to 'closing' 2025-05-09T09:50:43.685Z testcafe:browser:connection:7Bk8lap status changed to 'closing' 2025-05-09T09:50:43.689Z testcafe:browser:connection:zBob4cE TypeError: Cannot read properties of undefined (reading 'config') at BrowserProviderPluginHost.isHeadlessBrowser (/home/semaphore/Ultron/dashboard/dashboard/node_modules/testcafe/src/browser/provider/built-in/dedicated/base.js:69:51) at BrowserProvider.canUseDefaultWindowActions (/home/semaphore/Ultron/dashboard/dashboard/node_modules/testcafe/src/browser/provider/index.ts:266:53) at runNextTicks (node:internal/process/task_queues:60:5) at listOnTimeout (node:internal/timers:540:9) at processTimers (node:internal/timers:514:7) at BrowserProvider.closeBrowser (/home/semaphore/Ultron/dashboard/dashboard/node_modules/testcafe/src/browser/provider/index.ts:336:44) at BrowserConnection._closeBrowser (/home/semaphore/Ultron/dashboard/dashboard/node_modules/testcafe/src/browser/connection/index.ts:304:13) at BrowserConnection.close (/home/semaphore/Ultron/dashboard/dashboard/node_modules/testcafe/src/browser/connection/index.ts:513:9) at Function._closeConnection (/home/semaphore/Ultron/dashboard/dashboard/node_modules/testcafe/src/runner/browser-set.ts:58:9) 2025-05-09T09:50:43.690Z testcafe:browser:connection:zBob4cE status changed to 'closed' 2025-05-09T09:50:43.927Z testcafe:browser:connection:dOFzPdE status changed to 'closed' 2025-05-09T09:50:43.927Z testcafe:browser:connection:TgECtIu status changed to 'closed' 2025-05-09T09:50:43.927Z testcafe:browser:connection:f9lCb0h status changed to 'closed' 2025-05-09T09:50:43.927Z testcafe:browser:connection:TROGdAY status changed to 'closed' 2025-05-09T09:50:43.927Z testcafe:browser:connection:7Bk8lap status changed to 'closed' 2025-05-09T09:50:45.998Z testcafe:browser:connection:QVQ11bP status changed to 'closed' 2025-05-09T09:50:45.999Z testcafe:browser:connection:p0IyWG1 status changed to 'closed' 2025-05-09T09:50:45.999Z testcafe:browser:connection:icVv99X status changed to 'closed' 2025-05-09T09:50:46.000Z testcafe:browser:connection:HyrueS7 status changed to 'closed' 2025-05-09T09:50:46.000Z testcafe:browser:connection:Gz8Xlw9 status changed to 'closed' 2025-05-09T09:50:46.000Z testcafe:browser:connection:l-p8ZsK status changed to 'closed' 2025-05-09T09:50:46.001Z testcafe:browser:connection:wxZpikt status changed to 'closed' 2025-05-09T09:50:46.001Z testcafe:browser:connection:l1h8jkG status changed to 'closed' 2025-05-09T09:50:46.002Z testcafe:browser:connection:KfJX_XJ status changed to 'closed'
Version - 3.7.1
Browser Mozilla Firefox version - 130.0
and concurrency kept at 15 , faced this ^^
@saurabh-clevertap
Hello, thank you for sharing your results with us. However, we still need a reproducible example, which you can create as described here.
I haven't found a way to make this reproduce in a reliable way. I certainly would tell this group about it!
I've been able to occasionally reproduce the problem on testcafe 3.7.2, 3.7.0 and 3.6.2. It makes me think it isn't a regression in testcafe, but possibly something about the environment. Could it be nodejs? Chrome? Chrome driver? The github actions runner? There are a handful of things we could try pinning to older versions, but because we haven't found a way to reliably produce the bad effect every time, I don't know how to be sure which combination is good or bad. Maybe I'm on the wrong track with this.
The other thing I'm thinking about is - is there some way we can shine more light on the cause?
ERROR Cannot establish one or more browser connections.
1 of 2 browser connections have not been established:
chrome:headless
I reckon it would be useful to try to expose why the connection was not established. At the moment I'm guessing. Any advice would be terrific :)
Hello,
I was facing this issue too. In my setup the test runs in an k8s eks cluster and the test failed for me after testcafe image version 3.6.2
In my case the containerized detection does not work and in the end I detected the missing flag --disable-gpu which fixed it.
https://github.com/DevExpress/testcafe/blob/bcb561de6523985ce6787747edb47fce3c2634cc/src/browser/provider/built-in/dedicated/chrome/build-chrome-args.js#L1
So configuring these flags browsers: "chromium:headless --no-sandbox --disable-gpu --disable-dev-shm-usage" may help.
Greetings