webdriverio: [🐛 Bug]: v9: TypeError: fetch failed (ECONNREFUSED)
Have you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
WebdriverIO Version
9.0.9
Node.js Version
18.20.4
Mode
WDIO Testrunner
Which capabilities are you using?
{
'wdio:maxInstances': 1,
'wdio:enforceWebDriverClassic': true,
browserName: 'chrome',
browserVersion: '123',
'goog:chromeOptions': {
args: ['--disable-http2', '--headless', '--disable-dev-shm-usage', '--disable-gpu', '--no-sandbox', '--disable-extensions', '--accept-lang=de'],
prefs: {
'intl.accept_languages': 'de-DE',
'download.prompt_for_download': false,
'download.directory_upgrade': true,
'download.default_directory': pathToDownloadDirectory
}
},
acceptInsecureCerts: true
}
What happened?
Sporadically, the following error occurs:
TypeError: fetch failed
error properties: Object({ cause: Error: connect ECONNREFUSED 127.0.0.1:62837 })
at node:internal/deps/undici/undici:12618:11
Caused by: Error: connect ECONNREFUSED 127.0.0.1:62837
error properties: Object({ errno: -4078, code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 62837 })
at __node_internal_captureLargerStackTrace (node:internal/errors:496:5)
at __node_internal_exceptionWithHostPort (node:internal/errors:671:12)
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)
We have a large number of tests and I couldn’t find a pattern which tests fail and which not. It seems to be completely random. I even ran the tests on different machines, the error occurs seemingly on any machine (at least Windows 10 and 11).
The error did not occur with webdriverio 8.
What is your expected behavior?
The error should not occur.
How to reproduce the bug.
I am not able to create a reproducible example since the error seems to occur completely randomly.
Relevant log output
TypeError: fetch failed
error properties: Object({ cause: Error: connect ECONNREFUSED 127.0.0.1:62837 })
at node:internal/deps/undici/undici:12618:11
Caused by: Error: connect ECONNREFUSED 127.0.0.1:62837
error properties: Object({ errno: -4078, code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 62837 })
at __node_internal_captureLargerStackTrace (node:internal/errors:496:5)
at __node_internal_exceptionWithHostPort (node:internal/errors:671:12)
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)
Code of Conduct
- I agree to follow this project’s Code of Conduct
Is there an existing issue for this?
- I have searched the existing issues
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 19 (18 by maintainers)
I’m sorry to say it’s still not fixed. I don’t see the “Request timed out!” warnings so no retrying is done.
The reason might be what I found out here. So replacing
const errorCode = (response as RequestLibError).codewithconst errorCode = (response as RequestLibError).cause.codehere might fix it. Of course we would need to modify RequestLibError.