Skip to content

Add auto-abortion on timeout #31

Description

@webJose

Another potentially useful trigger for automatically aborting an HTTP request is a timeout value: If the call takes too long, let's bale out of it and inform the user.

Sample usage:

import { abortableRootFetcher, AbortReason } from './root-fetchers.js';

const response = await abortableRootFetcher
  .for<200, ...>()
  .get('/some/url', { autoAbort: { key: 'abc', timeout: 3_000 }});

if (response.aborted) {
  if (response.error.cause === AbortReason.timeout) {
    // Show the user a specialized message/UI.
  }
}

Here, AbortReason is an enumeration that developers can use to know the exact reason of the abortion.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions