From f4cae166ec8b5eeb15e0694ddbe076bbadd3defd Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 27 Mar 2024 14:18:27 +0200 Subject: [PATCH 1/3] Handle unexpected BFX API errors --- workers/loc.api/helpers/get-data-from-api.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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) } } From adf35fa39907a7dd0ed40333f5ba52cf6c3b7d0f Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 28 Mar 2024 12:55:54 +0200 Subject: [PATCH 2/3] Extend error logs for sync proc --- workers/loc.api/responder/index.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) 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) => { From fd18c3eae633feb029f4d047f0f13061288d668e Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 2 Apr 2024 16:01:45 +0300 Subject: [PATCH 3/3] Bump version up to 4.10.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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",