-
Notifications
You must be signed in to change notification settings - Fork 0
retry
awekrx edited this page May 29, 2026
·
1 revision
import { retry } from '@dev-suite/decorators/retry'
method
Retry transient failures with explicit and reusable policy.
- Inline retry loops and backoff logic
- Inconsistent retry handling per method
class BillingClient {
async charge(input: ChargeInput) {
for (let attempt = 1; attempt <= 3; attempt += 1) {
try {
return await this.http.post('/charge', input);
} catch (error) {
if (attempt === 3) throw error;
await sleep(250);
}
}
}
}import { retry } from '@dev-suite/decorators/retry';
class BillingClient {
@retry({ attempts: 3, delayMs: 250 })
async charge(input: ChargeInput) {
return this.http.post('/charge', input);
}
}- Retry policy is centralized and easy to audit.
- No control-flow clutter inside business methods.
class SyncService {
async push(batch: Batch) {
try {
return await this.remote.push(batch);
} catch (error) {
if (!isTransient(error)) throw error;
return this.remote.push(batch);
}
}
}import { retry } from '@dev-suite/decorators/retry';
class SyncService {
@retry({ attempts: 4, shouldRetry: (error) => isTransient(error) })
async push(batch: Batch) {
return this.remote.push(batch);
}
}- Selective retry avoids retrying permanent failures.
- Behavior can be aligned across multiple clients.