System Design · Junior · Question 34 of 75
Why set a timeout on network requests?
- ✓Correct answer: To avoid waiting forever and to show the user an error or retry
- 2So that requests run at a strictly defined time of day
- 3So that the browser doesn't cache the response longer than set
Explanation
fetch has no timeout by default: a "hung" request keeps the loading indicator spinning forever. Use AbortSignal.timeout(ms) and show a clear state with a retry button.