diff --git a/package.json b/package.json index 8c5c64ba..9d392565 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bfx-report", - "version": "4.10.0", + "version": "4.10.1", "description": "Reporting tool", "main": "worker.js", "license": "Apache-2.0", diff --git a/workers/loc.api/helpers/get-data-from-api.js b/workers/loc.api/helpers/get-data-from-api.js index 108a310f..2db98412 100644 --- a/workers/loc.api/helpers/get-data-from-api.js +++ b/workers/loc.api/helpers/get-data-from-api.js @@ -69,6 +69,7 @@ module.exports = ( let countNetError = 0 let countRateLimitError = 0 let countNonceSmallError = 0 + let countUnexpectedError = 0 let res = null while (true) { @@ -157,7 +158,17 @@ module.exports = ( continue } - throw err + // Handle unexpected BFX API errors + countUnexpectedError += 1 + + if (countUnexpectedError > 3) { + throw err + } + if (_isInterrupted(_interrupter)) { + return { isInterrupted: true } + } + + await _delay(10000, _interrupter) } } diff --git a/workers/loc.api/responder/index.js b/workers/loc.api/responder/index.js index a8e5817b..af64293a 100644 --- a/workers/loc.api/responder/index.js +++ b/workers/loc.api/responder/index.js @@ -144,7 +144,7 @@ const _getErrorWithMetadataForNonBaseError = (args, err) => { return err } -const _getErrorMetadata = (args, err) => { +const _getErrorMetadata = (args, err, name) => { const errWithMetadata = _getErrorWithMetadataForNonBaseError(args, err) _addStatusMessageToErrorMessage(errWithMetadata) const { @@ -178,8 +178,10 @@ const _getErrorMetadata = (args, err) => { data: extendedData } ) + const serializedError = _prepareErrorData(error, name) + Object.assign(error, { serializedError }) - return { code, message, data, error } + return { code, message, data, error, serializedError } } const _logError = (loggerArgs, err) => { @@ -195,8 +197,9 @@ const _logError = (loggerArgs, err) => { ) const { code, - error - } = _getErrorMetadata(args, err) + error, + serializedError + } = _getErrorMetadata(args, err, name) _emitEventByWs(loggerArgs, error) @@ -204,12 +207,12 @@ const _logError = (loggerArgs, err) => { code !== 500 || shouldNotBeLoggedToStdErrorStream ) { - logger.debug(_prepareErrorData(error, name)) + logger.debug(serializedError) return } - logger.error(_prepareErrorData(error, name)) + logger.error(serializedError) } const _emitEventByWs = (emitterArgs, error) => {