From db27e5a92c8feb98d1ddc0ee38b3bcaa4cc98444 Mon Sep 17 00:00:00 2001 From: nymkappa <1612910616@pm.me> Date: Wed, 5 Apr 2023 17:00:41 +0900 Subject: [PATCH] [esplora] print log when retrying unix socket - don't fallback to tcp socket on ETIMEDOUT --- backend/src/api/bitcoin/esplora-api.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/src/api/bitcoin/esplora-api.ts b/backend/src/api/bitcoin/esplora-api.ts index 15a6a6844..e471e4cde 100644 --- a/backend/src/api/bitcoin/esplora-api.ts +++ b/backend/src/api/bitcoin/esplora-api.ts @@ -29,9 +29,10 @@ class ElectrsApi implements AbstractBitcoinApi { fallbackToTcpSocket() { if (!this.unixSocketRetryTimeout) { - logger.err(`Unable to connect to esplora unix socket. Falling back to tcp socket. Retrying unix socket in ${config.ESPLORA.RETRY_UNIX_SOCKET_AFTER} seconds`); + logger.err(`Unable to connect to esplora unix socket. Falling back to tcp socket. Retrying unix socket in ${config.ESPLORA.RETRY_UNIX_SOCKET_AFTER / 1000} seconds`); // Retry the unix socket after a few seconds this.unixSocketRetryTimeout = setTimeout(() => { + logger.info(`Retrying to use unix socket for esplora now (applied for the next query)`); this.activeAxiosConfig = this.axiosConfigWithUnixSocket; }, config.ESPLORA.RETRY_UNIX_SOCKET_AFTER); } @@ -44,7 +45,7 @@ class ElectrsApi implements AbstractBitcoinApi { return axiosConnection.get(url, { ...this.activeAxiosConfig, responseType: responseType }) .then((response) => response.data) .catch((e) => { - if (e?.code === 'ECONNREFUSED' || e?.code === 'ETIMEDOUT') { + if (e?.code === 'ECONNREFUSED') { this.fallbackToTcpSocket(); // Retry immediately return axiosConnection.get(url, this.activeAxiosConfig)