diff options
author | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2017-11-10 21:45:20 +0200 |
---|---|---|
committer | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2017-11-10 21:45:20 +0200 |
commit | ed36f617197a1823bbbb13e4c8842752a27403ec (patch) | |
tree | e810f90dc2ff4bcb4c422c528850c7e8fae4f818 /node.d | |
parent | 903597ae64fe2edd9624303039aaeec2aa9a88a6 (diff) |
handle exceptions in node processor functions; fixes #2955
Diffstat (limited to 'node.d')
-rw-r--r-- | node.d/node_modules/netdata.js | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/node.d/node_modules/netdata.js b/node.d/node_modules/netdata.js index 143255d9e1..15110b74f0 100644 --- a/node.d/node_modules/netdata.js +++ b/node.d/node_modules/netdata.js @@ -68,6 +68,14 @@ var netdata = { modules_configuring: 0, charts: {}, + callback_protected: function(callback, param) { + try { + return callback(param); + } + catch(e) { + return null; + } + }, processors: { http: { @@ -90,7 +98,7 @@ var netdata = { if(end === false) { service.error('Got HTTP code ' + response.statusCode + ', failed to get data.'); end = true; - return callback(null); + return netdata.callback_protected(callback, null); } } @@ -102,7 +110,7 @@ var netdata = { if(end === false) { service.error(': Read error, failed to get data.'); end = true; - return callback(null); + return netdata.callback_protected(callback, null); } }); @@ -110,7 +118,7 @@ var netdata = { if(end === false) { if(__DEBUG === true) netdata.debug(service.module.name + ': ' + service.name + ': read completed.'); end = true; - return callback(data); + return netdata.callback_protected(callback, data); } }); }); @@ -118,7 +126,7 @@ var netdata = { req.on('error', function(e) { if(__DEBUG === true) netdata.debug('Failed to make request: ' + netdata.stringify(service.request) + ', message: ' + e.message); service.error('Failed to make request, message: ' + e.message); - return callback(null); + return netdata.callback_protected(callback, null); }); // write data to request body |