AbortController
AbortController signals cancellation to operations that support AbortSignal, including fetch. Cancellation is cooperative.
What it is
AbortController signals cancellation to operations that support AbortSignal, including fetch. Cancellation is cooperative.
Why it matters
Ignoring an old result is useful, but aborting can also avoid spending resources on a request that is no longer needed.
Example
Create a controller for a search request and abort it when a newer search replaces it.
Technical detail
Pass controller.signal to fetch and call controller.abort(). Distinguish cancellation from failures that need an error message.
When to use it
Use bounded fetches for optional model assets so a stalled request does not disable the basic experience.
Sources
More in Web platform
Assembled from the ReLU.chat curated knowledge base. These explanations are concise on purpose; check the sources for anything important.