Wraps a promise with a timeout and optional AbortSignal support.
For operations that support cancellation (like fetch), pass a function that
accepts an AbortSignal. The signal will be aborted when the timeout fires,
allowing the underlying operation to clean up resources.
Promise that resolves/rejects with the operation result or timeout
Throws
If the operation exceeds timeoutMs
Example
// With AbortSignal support (for fetch, etc.) awaitwithTimeoutAndAbort( (signal) =>fetch(url, { signal }), 5000, 'API request timed out' );
Security
Aborts the underlying operation via AbortController when the
timeout fires, preventing dangling fetch connections and resource leaks.
Per ISMS Policy SC-002, all external network calls must be cancellable.
Wraps a promise with a timeout and optional AbortSignal support.
For operations that support cancellation (like fetch), pass a function that accepts an AbortSignal. The signal will be aborted when the timeout fires, allowing the underlying operation to clean up resources.