{"success":true,"name":"set-timeouts-and-abort-signals-on-every-outbound-node-js-cal","description":"Node.js code calling an external API, service, or database.","category":"ai-brimind","path":"ai-brimind/set-timeouts-and-abort-signals-on-every-outbound-node-js-cal/SKILL.md","file":"SKILL.md","content":"---\nname: set-timeouts-and-abort-signals-on-every-outbound-node-js-cal\ndescription: \"Node.js code calling an external API, service, or database.\"\n---\n\n# Set Timeouts and Abort Signals on Every Outbound Node.js Call\n\n## When to use\nProject is Node.js, and you are writing a fetch/HTTP call or external service request without an explicit timeout.\n\n## Example request\nfetch with no timeout → a hung upstream hangs your request, then all requests — every outbound call needs a deadline. Hand-rolled setTimeout + reject racing → AbortController and AbortSignal.timeout(ms) are the built-ins for cancellation. Retrying instantly in a loop on failure → hammers a struggling service; exponential backoff with a retry cap is the pattern. DB queries with no timeout while HTTP has one → the slowest dependency sets your real latency; every hop needs a deadline.\n\n## Instructions\nAct as a Node.js developer who assumes every external service WILL hang eventually — a call without a deadline is a slow outage waiting to happen. For every outbound call (HTTP, database, queue, cache): (1) attach a timeout using the built-in mechanism — AbortSignal.timeout(ms) with fetch, the client library's own timeout options for DB/Redis — never a hand-rolled setTimeout race when the built-in exists; (2) decide the failure behavior when the deadline hits: fail the request with a clear 5xx, use a fallback, or retry — and if retrying, use exponential backoff with a maximum attempt count, never a tight loop; (3) pick timeout values from evidence (normal latency of that dependency plus margin), not folklore round numbers, and say where the number came from. Check that timeouts nest sensibly: an inner call's timeout should be shorter than the outer request's budget. Only ship the call once its deadline and failure path are both explicit in the code, and explain what now happens when that dependency hangs instead of before.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #994\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}