How to ignore getaddrinfo ENOTFOUND in NestJS (using TypeORM)

81 views Asked by At

We have a NestJS application which is using TypeORM for the database layer.

We are doing a lot of requests to the database, sometimes the DB refuses the connection and even after some retries it returns getaddrinfo ENOTFOUND error.

Our goal is not let this error to crash our NestJS application, because saving the data into DB is "optional" and we are periodically checking the DB if there are all of the data that should be there.

Error: getaddrinfo ENOTFOUND HIDDEN_DB.cockroachlabs.cloud at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26)

We can restart the pod, but this should be done after the whole data completion is done.

How can we handle this exception?

Try catch didn't help.

0

There are 0 answers