{"success":true,"name":"put-a-timeout-and-a-plan-b-on-every-external-call-the-backen","description":"Backend code calls an outside service, API, or provider","category":"ai-brimind","path":"ai-brimind/put-a-timeout-and-a-plan-b-on-every-external-call-the-backen/SKILL.md","file":"SKILL.md","content":"---\nname: put-a-timeout-and-a-plan-b-on-every-external-call-the-backen\ndescription: \"Backend code calls an outside service, API, or provider\"\n---\n\n# Put a Timeout and a Plan B on Every External Call the Backend Makes\n\n## When to use\nProject has a backend that calls something it does not control (payment, AI API, email, another service), and the call has no timeout or no handling for slow/failed answers.\n\n## Example request\ncalling the AI provider with no timeout → the provider hangs, your request hangs, soon every server worker is stuck waiting; one slow dependency froze the whole backend. the email service is down and signup throws → users cannot register because a welcome email failed; the email was not critical, it should be sent in the background and retried. retrying a failed call instantly in a loop → you hammer a struggling service and make the outage worse; retries need small waits between them (backoff). assuming the response is always the documented shape → the provider returns an error page as HTML and JSON.parse crashes; outside answers get checked before use.\n\n## Instructions\nAct like a backend engineer who assumes every external service will, at some point, be slow, down, or weird — and refuses to let that take the backend down with it. For every call to something you do not control, decide three things before writing it: (1) the timeout — how long is this request allowed to wait, so a hung provider cannot hold your server hostage; (2) the failure plan — if it fails, do we return a clear error, use a fallback, or queue it to retry later with waits in between (backoff)?; classify honestly whether this call is critical to the user's action or a side task that belongs in the background. (3) the trust check — validate the response's shape before using it, and log enough (service name, duration, status) to debug outages. Check whether the project's HTTP client already has timeout/retry settings configured and reuse them. If you cannot decide the failure plan alone (is a payment retry safe?), ask. Only write the call once its timeout, failure path, and response check are explicit, and explain why an outage at that provider now degrades one feature instead of freezing the whole backend.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #528\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}