From 5c39138bc1a049cc087c4c159bc810ec74248bc7 Mon Sep 17 00:00:00 2001 From: TaprootFreak <142087526+TaprootFreak@users.noreply.github.com> Date: Thu, 26 Feb 2026 22:32:15 +0100 Subject: [PATCH] fix: wrap native coin balance call in try-catch for payment balances getNativeCoinBalanceForAddress was not protected by error handling, unlike getTokenBalances. When a blockchain node becomes unresponsive (e.g. Firo RPC timeout), the unhandled error propagates through Promise.all and crashes the entire saveTradingLog cron job, stopping all FinancialDataLog and FinancialChangesLog entries. --- .../services/payment-balance.service.ts | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/subdomains/core/payment-link/services/payment-balance.service.ts b/src/subdomains/core/payment-link/services/payment-balance.service.ts index 31cfebdd75..38e3c6b400 100644 --- a/src/subdomains/core/payment-link/services/payment-balance.service.ts +++ b/src/subdomains/core/payment-link/services/payment-balance.service.ts @@ -83,16 +83,16 @@ export class PaymentBalanceService implements OnModuleInit { const coin = assets.find((a) => a.type === AssetType.COIN); const tokens = assets.filter((a) => a.type !== AssetType.COIN); - if (coin) { - balanceMap.set(coin.id, { - owner: targetAddress, - contractAddress: coin.chainId, - balance: await client.getNativeCoinBalanceForAddress(targetAddress), - }); - } + try { + if (coin) { + balanceMap.set(coin.id, { + owner: targetAddress, + contractAddress: coin.chainId, + balance: await client.getNativeCoinBalanceForAddress(targetAddress), + }); + } - if (tokens.length) { - try { + if (tokens.length) { const tokenBalances = await client.getTokenBalances(tokens, targetAddress); for (const token of tokens) { const balance = tokenBalances.find((b) => b.contractAddress === token.chainId)?.balance; @@ -104,11 +104,11 @@ export class PaymentBalanceService implements OnModuleInit { balance, }); } - } catch (e) { - if (!catchException) throw e; - - this.logger.error(`Error getting payment balances for blockchain ${chain}:`, e); } + } catch (e) { + if (!catchException) throw e; + + this.logger.error(`Error getting payment balances for blockchain ${chain}:`, e); } }), );