Wrap the Fetch API with an Automatic Timeout and Abort Mechanism
Implement a fetchWithTimeout(url, options, timeoutMs) utility that wraps the native fetch() and automatically cancels the request if it doesn't complete within the given milliseconds. Use AbortController to signal cancellation and race it against the actual fetch call. Properly clean up the timeout on success to avoid memory leaks. Return a rejected promise with a meaningful timeout error. This is a production-critical pattern for resilient API calls in any frontend application.