Skip to content

[Documentation] Add example for request cancellation using AbortController #7263

@harsha08-2k6

Description

@harsha08-2k6

Section/Content To Improve

Section/Content To Improve

The examples folder currently lacks a clear, practical example demonstrating how to cancel ongoing HTTP requests using the modern AbortController API.

Suggested Improvement

I would like to propose adding a new example file /examples/abort-controller/index.html (or similar) that demonstrates:

  1. How to cancel a single request using AbortController
  2. How to cancel multiple concurrent requests
  3. Proper cleanup and error handling when a request is aborted
  4. Real-world use case: canceling a request when a user navigates away or performs a new search

Motivation

Request cancellation is a common requirement in modern web applications, especially for:

  • Search-as-you-type functionality
  • Preventing race conditions
  • Improving performance by canceling unnecessary requests
  • Better user experience when navigating between pages

While the documentation mentions AbortController support, a practical example would greatly help developers implement this feature correctly.

Additional Context

I'm happy to contribute a PR for this example if the maintainers agree it would be a valuable addition to the examples collection.

Suggested Improvement

Add a comprehensive example demonstrating request cancellation using AbortController API with practical use cases like search-as-you-type and handling race conditions.

Relevant File(s)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions