{"success":true,"name":"put-a-timeout-on-every-outbound-call-never-wait-forever","description":"Writing backend or frontend code that calls an API, DB, or external service","category":"ai-brimind","path":"ai-brimind/put-a-timeout-on-every-outbound-call-never-wait-forever/SKILL.md","file":"SKILL.md","content":"---\nname: put-a-timeout-on-every-outbound-call-never-wait-forever\ndescription: \"Writing backend or frontend code that calls an API, DB, or external service\"\n---\n\n# Put a Timeout on Every Outbound Call: Never Wait Forever\n\n## When to use\nWriting backend or frontend code that calls an API, DB, or external service\n\n## Example request\nBackend calls a payment provider with default settings → provider hangs, your request hangs, users stare at a spinner forever; the missing piece is a timeout. One slow external API makes your whole server stop answering → each stuck request holds a connection; timeouts free them, this is basic 'resource protection'. Frontend fetch never resolves on bad wifi → the loading spinner never ends and the user cannot retry; an AbortController with a time limit turns 'stuck' into a clear error. A DB query on a huge table runs for minutes → a query timeout turns a silent freeze into a visible, fixable error message.\n\n## Instructions\nAct as a developer who treats every call leaving the process as a call that might never come back. For each outbound call you write or touch (HTTP request, DB query, external service), do the following: (1) Point at the exact line and ask: 'if the other side never answers, how long do we wait?' If the honest answer is 'forever' or 'whatever the default is', fix it now. (2) Set an explicit timeout using the tool's real mechanism — the timeout option in axios or the HTTP client, an AbortController with fetch, the query/connection timeout setting of the DB driver — do not hand-roll timers when the library already has a built-in for this. (3) Choose a value with a reason: a few seconds for user-facing requests, longer for background jobs; say why you picked the number. (4) Decide what happens ON timeout — return a clear error to the user, log it with which service failed, and make sure the failure path is handled like any other error, not swallowed. (5) Never let a timeout leave the system half-done silently: if the call was a write, note that it may or may not have succeeded on the other side, and handle that honestly. Only move on once every outbound call in your change has an explicit limit and a named behavior for when that limit is hit — waiting forever is not a strategy.\n\n## Metadata\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #188\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}