From 17dd83de10b32788e02bc2b2198dbcc61efead61 Mon Sep 17 00:00:00 2001 From: tripathyr Date: Thu, 20 May 2021 09:40:40 +0530 Subject: [PATCH] db index.js asserts removed for resilience --- lib/services/db/index.js | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/lib/services/db/index.js b/lib/services/db/index.js index 323509ec..1bcc57ef 100644 --- a/lib/services/db/index.js +++ b/lib/services/db/index.js @@ -50,7 +50,6 @@ DB.prototype._onError = function(err) { if (!this._stopping) { log.error('Db Service: error: ' + err); //FLO Crash Error Resolution by RanchiMall 10th May 2021 - //return this.node.stop(); //this.node.stop(); } }; @@ -119,7 +118,9 @@ DB.prototype.get = function(key, options, callback) { } else { - cb(new Error('Shutdown sequence underway, not able to complete the query')); + // FLOSight Error Correction from RanchiMall 20th May 2021. + //cb(new Error('Shutdown sequence underway, not able to complete the query')); + log.error('Shutdown sequence underway, not able to complete the query'); } }; @@ -130,11 +131,19 @@ DB.prototype.put = function(key, value, callback) { callback(); } - assert(Buffer.isBuffer(key), 'key NOT a buffer as expected.'); + // FLOSight Error Correction from RanchiMall 20th May 2021. removed the unhandled assert and replaced by looging of error + if (Buffer.isBuffer(key) == false) { + log.error('key NOT a buffer as expected.'); + } + // assert(Buffer.isBuffer(key), 'key NOT a buffer as expected.'); if (value) { - - assert(Buffer.isBuffer(value), 'value exists but NOT a buffer as expected.'); + + // FLOSight Error Correction from RanchiMall 20th May 2021. removed the unhandled assert and replaced by looging of error + if (Buffer.isBuffer(value) == false) { + log.error('value exists but NOT a buffer as expected.'); + } + //assert(Buffer.isBuffer(value), 'value exists but NOT a buffer as expected.'); } @@ -149,11 +158,18 @@ DB.prototype.batch = function(ops, callback) { for(var i = 0; i < ops.length; i++) { - assert(Buffer.isBuffer(ops[i].key), 'key NOT a buffer as expected.'); + // FLOSight Error Correction from RanchiMall 20th May 2021. removed the unhandled assert and replaced by looging of error + if (Buffer.isBuffer(ops[i].key) == false) { + log.error('key NOT a buffer as expected.'); + } + //assert(Buffer.isBuffer(ops[i].key), 'key NOT a buffer as expected.'); if (ops[i].value) { - - assert(Buffer.isBuffer(ops[i].value), 'value exists but NOT a buffer as expected.'); + // FLOSight Error Correction from RanchiMall 20th May 2021. removed the unhandled assert and replaced by looging of error + if (Buffer.isBuffer(ops[i].value) == false) { + log.error('value exists but NOT a buffer as expected.'); + } + //assert(Buffer.isBuffer(ops[i].value), 'value exists but NOT a buffer as expected.'); } }