This document provides a comprehensive audit of all external calls in the codebase and their timeout implementations.
File: src/services/StellarService.js
| Method | External Call | Timeout | Retry | Status |
|---|---|---|---|---|
loadAccount() |
server.loadAccount() |
15s | 3x | ✅ Protected |
submitTransaction() |
server.submitTransaction() |
30s | Network safety | ✅ Protected |
friendbot() |
server.friendbot().call() |
15s | 3x | ✅ Protected |
transaction() |
server.transaction().call() |
15s | 3x | ✅ Protected |
transactions() |
server.transactions().call() |
15s | 3x | ✅ Protected |
streamTransactions() |
server.transactions().stream() |
60s inactivity | Auto-reconnect | ✅ Protected |
Implementation Details:
- All calls wrapped with
withTimeout()via_executeWithRetry() - Exponential backoff: 200ms → 400ms → 800ms (max 2s)
- TimeoutError treated as transient and retryable
- Streaming has inactivity monitoring with automatic cleanup
File: src/utils/database.js
| Method | External Call | Timeout | Status |
|---|---|---|---|
getConnection() |
new sqlite3.Database() |
10s | ✅ Protected |
query() |
db.all() |
10s | ✅ Protected |
run() |
db.run() |
10s | ✅ Protected |
get() |
db.get() |
10s | ✅ Protected |
Implementation Details:
- All operations wrapped with
withTimeout() - Automatic connection cleanup on timeout
- Prevents connection leaks
- Clear error messages with operation context
File: src/services/RecurringDonationScheduler.js
| Operation | External Dependency | Timeout | Status |
|---|---|---|---|
processSchedules() |
Database queries | 10s | ✅ Protected (via Database) |
executeSchedule() |
stellarService.sendPayment() |
30s | ✅ Protected (via StellarService) |
logExecution() |
Database writes | 10s | ✅ Protected (via Database) |
Additional Protection:
- Retry logic: 3 attempts with exponential backoff (1s → 2s → 4s, max 30s)
- Duplicate execution prevention
- Execution timeout tracking
File: src/services/TransactionReconciliationService.js
| Operation | External Dependency | Timeout | Status |
|---|---|---|---|
reconcile() |
Database queries | 10s | ✅ Protected (via Database) |
reconcileTransaction() |
stellarService.verifyTransaction() |
15s | ✅ Protected (via StellarService) |
Additional Protection:
- 5-minute reconciliation interval
- Concurrent reconciliation prevention
- Promise.allSettled for parallel processing
File: src/services/TransactionSyncService.js
| Operation | External Dependency | Timeout | Status |
|---|---|---|---|
syncWalletTransactions() |
stellarService.getTransactionHistory() |
15s | ✅ Protected (via StellarService) |
| Database writes | Database operations | 10s | ✅ Protected (via Database) |
All routes use services with timeout protection:
- Donation routes → StellarService (protected)
- Wallet routes → StellarService (protected)
- Transaction routes → Database + StellarService (protected)
| Component | Default Timeout | Configurable | Retry | Notes |
|---|---|---|---|---|
| Stellar API | 15s | Yes | 3x | Standard operations |
| Stellar Submit | 30s | Yes | Network safety | Transaction submission |
| Stellar Stream | 60s | Yes | Auto-reconnect | Inactivity timeout |
| Database | 10s | No* | No | All DB operations |
*Can be modified in TIMEOUT_DEFAULTS constant
{
name: 'TimeoutError',
message: 'Operation X timed out after Yms',
operation: 'operation_name',
timeoutMs: 15000,
timestamp: '2026-02-26T...'
}- DEBUG: Retry attempts
- WARN: Timeout with retry available
- ERROR: Final timeout failure
- INFO: Successful recovery after timeout
- All Stellar Horizon API calls
- All database operations
- All background service operations
- Transaction streaming
- Express request timeout (handled by Express/Node.js)
- File system operations (OS-level timeouts)
- No unprotected external HTTP calls
- No unprotected third-party API calls
- No unprotected network sockets
- All Stellar API calls have timeouts
- All database operations have timeouts
- Streaming connections monitored
- Timeout errors logged clearly
- Graceful error handling implemented
- Connection cleanup on timeout
- Retry logic for transient errors
- Documentation complete
- No syntax errors
- Backward compatible
-
timeoutHandler.js- Test withTimeout() enforcement
- Test TimeoutError creation
- Test executeWithTimeout() retry logic
-
StellarService.js- Test timeout on slow API calls
- Test retry on timeout
- Test stream inactivity timeout
-
database.js- Test query timeout
- Test connection cleanup
- Test timeout error handling
- End-to-end donation with simulated network delay
- Database timeout under load
- Stream reconnection after timeout
- Background service timeout handling
- Concurrent operations under timeout
- Database connection pool under timeout
- Stellar API rate limiting with timeouts
- Review timeout values for production environment
- Set up monitoring for TimeoutError occurrences
- Configure alerting for high timeout rates
- Test with production-like network latency
- Monitor timeout frequency
- Adjust timeout values if needed
- Track retry success rates
- Monitor for connection leaks
- Monthly: Review timeout metrics
- Quarterly: Adjust timeout values based on data
- Annually: Audit for new external calls
- New external API integrations
- New database operations
- New streaming connections
- Performance degradation observed