Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Retry a flaky operation once before treating it as a real error
Use a bounded retry for transient failures only when repeating the operation is safe and respects the caller deadline.
Bad example
| 1 | const token = await getToken(); // throws on a transient first-attempt failure |
Explanation (EN)
A recoverable transient failure can warrant one extra attempt, but catch-all retries can duplicate effects.
Objašnjenje (HR)
Good example
| 1 | try { |
| 2 | return await readResource(); |
| 3 | } catch (error) { |
| 4 | if (!isTransientReadFailure(error)) throw error; |
| 5 | await waitForRetry(signal); |
| 6 | return await readResource(); |
| 7 | } |
Explanation (EN)
The retry is limited to an idempotent read and classified transient failure; a second failure propagates.
Objašnjenje (HR)
Notes (EN)
Retry only classified transient failures of operations proven safe to repeat, within a bounded attempt/deadline budget and with appropriate delay/cancellation. Inspect transport defaults as well as application retries. A version-checked mutation is not automatically safe to replay after an ambiguous timeout: the first attempt may have committed and the replay can conflict. Disable automatic mutation replay unless an idempotency/reconciliation protocol handles this, and count all transport attempts against the operation deadline.
Exceptions / Tradeoffs (EN)
Authentication/validation errors are not fixed by blind retries. A timed-out mutation may already have committed; require idempotency or a deduplication key.