I’ve been facing this error while trying to npm run dev-api
on my Linux machine.
I followed the steps mentioned here
TypeError: fetch failed
at node:internal/deps/undici/undici:13502:13
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async request (/home/apoorva/cht-core/shared-libs/couch-request/src/couch-request.js:209:20)
at async getCouchDbVersion (/home/apoorva/cht-core/shared-libs/server-checks/src/checks.js:96:20)
at async Object.checkCouchDbVersion (/home/apoorva/cht-core/shared-libs/server-checks/src/checks.js:101:19)
at async checkCouchDb (/home/apoorva/cht-core/shared-libs/server-checks/src/index.js:27:7)
at async Object.check (/home/apoorva/cht-core/shared-libs/server-checks/src/index.js:43:5)
at async /home/apoorva/cht-core/api/server.js:23:5 {
[cause]: ConnectTimeoutError: Connect Timeout Error (attempted address: localhost:5984, timeout: 10000ms)
at onConnectTimeout (node:internal/deps/undici/undici:2602:28)
at Immediate._onImmediate (node:internal/deps/undici/undici:2583:11)
at process.processImmediate (node:internal/timers:491:21) {
code: 'UND_ERR_CONNECT_TIMEOUT'
}
}
Not sure why that is the case I can go to http://localhost:5984
on my browser using medic:password
for authentication to get the image attached as the response.
Using
curl
has the same effect:
➜ cht-core git:(master) ✗ curl -u medic:password http://localhost:5984/
{"couchdb":"Welcome","version":"3.4.2","git_sha":"6e5ad2a5c","uuid":"f999d114-f8d7-43f8-8af5-8af15a449a75","features":["access-ready","partitioned","pluggable-storage-engines","reshard","scheduler"],"vendor":{"name":"The Apache Software Foundation"}}
{
method: 'GET',
headers: {
authorization: 'Basic bWVkaWM6cGFzc3dvcmQ=',
accept: 'application/json',
'content-type': 'application/json'
},
uri: 'http://localhost:5984/'
}
This is logged from couch-request.js
diff --git a/shared-libs/couch-request/src/couch-request.js b/shared-libs/couch-request/src/couch-request.js
index 122b342d1..5860ca125 100644
--- a/shared-libs/couch-request/src/couch-request.js
+++ b/shared-libs/couch-request/src/couch-request.js
@@ -205,7 +205,7 @@ const sanitizeErrorResponse = (body) => {
};
const request = async (options = {}) => {
await setRequestOptions(options);
-
+ console.log(options);
const response = await global.fetch(options.uri, options);
const responseObj = {
...response,
This works fine on my WSL setup, but not on my Linux Mint setup.
Thanks.