Capacitor HTTP Plugin and AbortController: Current Cancellation Support?
0 reputation · 09 Sept 2024, 13:23 UTC
When building mobile or web applications with Capacitor, developers often rely on the HTTP plugin for network requests. A common requirement is to cancel or timeout a request gracefully, especially for large payloads or slow connections. The plugin provides a timeout option that rejects the promise after a specified duration, but the underlying network request continues to run in the background. Additionally, the plugin does not honour an AbortSignal passed via AbortController, and there is no distinct error type for timeouts.
These behaviors create uncertainty about how to efficiently manage resources and provide consistent error handling across platforms. There is no documented plan or open issue tracking the addition of a native cancellation API, leaving developers unsure whether future releases will address this gap.
- Does Capacitor plan to expose a cancellation API that aborts the underlying network request?
- If a cancellation API is introduced, will it coexist with the existing
timeoutoption or replace it? - What best‑practice pattern should be recommended for developers to avoid wasted bandwidth after a timeout?