From 67cf47a52b277d2111f033bf5bb91cfbda9cabda Mon Sep 17 00:00:00 2001 From: missinglink Date: Thu, 31 Oct 2019 11:48:46 +0100 Subject: [PATCH] feat(debugging): improved logging of batch indexing error --- package.json | 3 ++- src/transaction.js | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index fe203b8..0c3a2c6 100644 --- a/package.json +++ b/package.json @@ -36,8 +36,9 @@ "tape": "^4.4.0" }, "dependencies": { - "elasticsearch": "^16.0.0", "@hapi/joi": "^15.0.0", + "elasticsearch": "^16.0.0", + "lodash": "^4.17.15", "pelias-config": "^4.0.0", "pelias-logger": "^1.2.1", "through2": "^3.0.0" diff --git a/src/transaction.js b/src/transaction.js index f5e598b..d7b5d33 100644 --- a/src/transaction.js +++ b/src/transaction.js @@ -1,3 +1,4 @@ +const _ = require('lodash'); const pelias_logger = require( 'pelias-logger' ); var max_retries = 5; @@ -62,6 +63,11 @@ function wrapper( client, parent_logger ){ if( task.status > 201 ){ logger.error( '[' + action.status + ']', action.error ); + + // additional debugging output of the error and corresponding request + var req = batch._slots.filter(s => _.get(s, 'cmd.index._id') === action._id); + logger.info(JSON.stringify(action, null, 2)); + logger.info(JSON.stringify(req, null, 2)); } // else { // delete task.cmd; // reclaim memory