Skip to content

Conversation

@TaprootFreak
Copy link
Collaborator

@TaprootFreak TaprootFreak commented Jan 2, 2026

Summary

Graceful degradation for services when external dependencies are unavailable in local development mode.

Commits (6)

  1. Log missing config warnings only once - Initial warning-once pattern
  2. Skip services gracefully when dependencies are unavailable - Add availability checks
  3. Add missing null checks for graceful degradation - Handle null clients
  4. Make warning-once pattern consistent across all services - Consistent Set
  5. Add readonly to syncWarningsLogged Set for consistency - Code style fix
  6. Add missing blank line after early return for consistency - Formatting fix

Pattern Overview

Pattern Use Case Services
private unavailableWarningLogged = false Single dependency BitcoinStrategy, CheckoutObserver, FiatPayInSyncService, BankTxService
private readonly ...Set<Blockchain>() Multi-blockchain PaymentBalanceService, LogJobService, TransactionHelper
private readonly ...Set<string>() Multi-exchange ExchangeTxService

Changes by File (10 files, +79/-10 lines)

File Change
checkout.service.ts Add isAvailable()
exchange-tx.service.ts Error → Warning-once
checkout.observer.ts Add availability check
payment.observer.ts Fix null pointer
payment-balance.service.ts Add null checks + warning-once
bank-tx.service.ts Add warning-once
fiat-payin-sync.service.ts Add availability check
log-job.service.ts Add null check + warning-once
bitcoin.strategy.ts Add warning-once
transaction-helper.ts Add null check + warning-once

Quality Checklist

  • All Set<> fields use readonly
  • Consistent naming conventions
  • Consistent message format
  • Consistent blank lines after early returns
  • TypeScript compiles without errors
  • All tests pass (48/48)
  • Manual verification: warnings appear only once
  • Manual verification: no null pointer errors

Prevent log spam by tracking if warning was already logged.
Affects high-frequency cron jobs:
- BitcoinStrategy (every second)
- BankTxService (every 30 seconds)
- Add isAvailable() check to CheckoutService
- Add availability check to CheckoutObserver with warning-once pattern
- Add availability check to FiatPayInSyncService with warning-once pattern
- Change ExchangeTxService to warn-once on sync failures
- Add null check for client in TransactionHelper.getNetworkStartFee
- Add null check for client in LogJobService.getAssetLog
- Fix PaymentObserver to use optional chaining for outputDate
- Add null checks for client and targetAddress in PaymentBalanceService
- Also check for coin existence before setting balance
- Extend CheckoutService.isAvailable() to also check Config.checkout.entityId
- Add warning-once with Set<Blockchain> to PaymentBalanceService
- Add warning-once with Set<Blockchain> to LogJobService
- Add warning-once with Set<Blockchain> to TransactionHelper

All services now consistently log warnings only once when
blockchain clients are not configured.
@TaprootFreak TaprootFreak merged commit f690d42 into develop Jan 2, 2026
1 check passed
@TaprootFreak TaprootFreak deleted the fix/log-warnings-only-once branch January 2, 2026 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants