From feaecba71cd391ef09d8277c2590694ba7e9e356 Mon Sep 17 00:00:00 2001 From: Muhammad Aaqil Date: Fri, 24 Nov 2023 22:40:10 +0500 Subject: [PATCH] fix: add error handling in case of unvailable cache server Signed-off-by: Muhammad Aaqil --- lib/datasource.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/datasource.js b/lib/datasource.js index 33e9add5..1c96fd74 100644 --- a/lib/datasource.js +++ b/lib/datasource.js @@ -499,7 +499,15 @@ DataSource.prototype.setup = function(dsName, settings) { debug('Connection fails: %s\nIt will be retried for the next request.', err); } else { g.error('Connection fails: %s\nIt will be retried for the next request.', err); - this.emit('error', err); + if (settings.catchFailure) { + try { + this.emit('error', err); + } catch (error) { + console.log(error); + } + } else { + this.emit('error', err); + } } } else { // Either lazyConnect or connector initialize() defers the connection