Always Add Timeouts to External API Calls
Never call external APIs without a timeout — one slow dependency can freeze your entire system.
One silent production killer: calling external APIs without a timeout.
If a third-party service hangs, your request hangs too… and suddenly:
- API response time spikes
- Threads get blocked
- Users see loading forever
Most developers assume APIs will respond quickly. They don’t.
Always define a timeout.
Example:
- Payment APIs
- Email services
- AI APIs
- Internal microservices
Without timeout:
→ your system depends on someone else’s uptime
With timeout:
→ your system stays in control
Bonus:
Also implement retry logic with limits.
Rule:
“No timeout = future production issue”
More Daily Dev Tips
Stop Using map() for Side Effects
Using Array.map() for side effects leads to confusing code and unnecessary memory usage.
💡Don’t Hide Errors Behind Generic Toasts
A “Something went wrong” message helps nobody. Log the real error and show users what they can do next.
💡Validate Request Payloads at the API Boundary
Never trust incoming request data. Validate it at the API boundary before it touches business logic or the database.
Get a new Daily Dev Tip in your inbox
Subscribe to Stack Dev Life — free, no spam, unsubscribe anytime.
Subscribe free →