Skip to main content

electron/utils/retry

Retry utility for handling transient failures in database and network operations.

Remarks

Provides configurable retry logic with a fixed delay between attempts for robust error handling in backend operations. Useful for dealing with temporary network issues, database locks, or other transient failures.

Example

// Simple retry with defaults
const result = await withRetry(() => fetchData());

// Retry with custom configuration
const result = await withRetry(() => database.query(sql), {
maxRetries: 3,
delayMs: 1000,
operationName: "database query",
onError: (error, attempt) => logger.warn(`Attempt ${attempt} failed`),
});

Functions