{"success":true,"name":"add-retry-with-backoff-to-flaky-network-calls","description":"A network call sometimes fails randomly and you handle it with one try.","category":"ai-brimind","path":"ai-brimind/add-retry-with-backoff-to-flaky-network-calls/SKILL.md","file":"SKILL.md","content":"---\nname: add-retry-with-backoff-to-flaky-network-calls\ndescription: \"A network call sometimes fails randomly and you handle it with one try.\"\n---\n\n# Add Retry With Backoff to Flaky Network Calls\n\n## When to use\nCode makes network requests that can fail temporarily (timeouts, 502/503, dropped connections), and a single failure currently means the whole operation fails.\n\n## Example request\nOne timeout kills the whole sync → the same request works 2 seconds later; a single retry would have saved it — transient vs permanent failure. Retrying instantly in a tight loop → hammers a struggling server and makes it worse — exponential backoff. Retrying a payment POST blindly → the charge happens twice — only retry safe (idempotent) operations.\n\n## Instructions\nAct like a developer who expects the network to fail occasionally and plans for it. When adding resilience to a request: (1) classify the failure first — transient errors (timeout, 502/503, connection reset) deserve retries; permanent ones (400 bad request, 401/403 auth) do NOT, retrying them is noise; (2) retry with exponential backoff — wait e.g. 1s, then 2s, then 4s — and cap total attempts (3 is a sane default), never a tight instant loop; (3) verify the operation is safe to repeat: GETs usually are; POSTs that create or charge things are not, unless the server supports an idempotency key — if repeating could duplicate an action, do not auto-retry, surface the error instead; (4) check whether the HTTP library in use already has retry support built in before hand-rolling timers. After retries are exhausted, fail loudly with the real error, not silently. Only proceed once you can state which errors retry, how many times, with what delays, and why repeating this specific call cannot cause duplicates.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #1015\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}