Add a timeout to mongoldb connections (#15258)

* Add option to set a socket timeout for mongodb requests

* Handle mongodb timeouts better

* add default to config
This commit is contained in:
Phillip Thelen
2024-08-01 17:28:54 +02:00
committed by GitHub
parent 7f6ae8ffbf
commit 15f104ddd0
5 changed files with 29 additions and 0 deletions

View File

@@ -9,6 +9,7 @@ import {
CustomError,
BadRequest,
InternalServerError,
RequestTimeout,
} from '../libs/errors';
export default function errorHandler (err, req, res, next) { // eslint-disable-line no-unused-vars
@@ -46,6 +47,10 @@ export default function errorHandler (err, req, res, next) { // eslint-disable-l
}));
}
if (err.name === 'MongoNetworkTimeoutError') {
responseErr = new RequestTimeout();
}
// Handle Stripe Card errors errors (can be safely shown to the users)
// https://stripe.com/docs/api/node#errors
if (err.type === 'StripeCardError') {