improve error handling with rpc response API
This commit is contained in:
@@ -772,7 +772,9 @@ HK.initializeIndexWorkers = function (Env, config, _cb) {
|
||||
|
||||
const workers = [];
|
||||
|
||||
const response = Util.response();
|
||||
const response = Util.response(function (errLabel, info) {
|
||||
Env.Log.error('HK_DB_WORKER__' + errLabel, info);
|
||||
});
|
||||
const initWorker = function (worker, cb) {
|
||||
//console.log("initializing index worker");
|
||||
const txid = Util.uid();
|
||||
@@ -798,14 +800,7 @@ HK.initializeIndexWorkers = function (Env, config, _cb) {
|
||||
return;
|
||||
}
|
||||
//console.log(res);
|
||||
try {
|
||||
response.handle(res.txid, [res.error, res.value]);
|
||||
} catch (err) {
|
||||
Env.Log.error("INDEX_WORKER", {
|
||||
error: err,
|
||||
response: res,
|
||||
});
|
||||
}
|
||||
response.handle(res.txid, [res.error, res.value]);
|
||||
});
|
||||
worker.on('exit', function () {
|
||||
var idx = workers.indexOf(worker);
|
||||
@@ -945,7 +940,9 @@ HK.initializeValidationWorkers = function (Env) {
|
||||
workers.push(fork('lib/workers/check-signature.js'));
|
||||
}
|
||||
|
||||
const response = Util.response();
|
||||
const response = Util.response(function (errLabel, info) {
|
||||
Env.Log.error('HK_VALIDATE_WORKER__' + errLabel, info);
|
||||
});
|
||||
|
||||
var initWorker = function (worker) {
|
||||
worker.on('message', function (res) {
|
||||
|
||||
Reference in New Issue
Block a user