Skip to content

Core HTTP fetch service doesn't return AbortError #51406

@lukasolson

Description

@lukasolson

When aborting a request using the core HTTP fetch, the error it returns has a generic name of 'Error', rather than an AbortError (see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).

Note: When abort() is called, the fetch() promise rejects with an AbortError.

I understand we're using our own fetch service but it would be nice if we had a specific, possibly typed, error that we can use to know in the handler whether the request was aborted or if the error was some other kind of error. At the very least it'd be nice if the error's name was AbortError, similar to how most browsers implement fetch.

Code example:

http.fetch(`/api/foo`, {
  method: 'GET'
  signal,
}).catch(e => {
  // If the `signal` was aborted:
  console.log('name', e.name); // 'Error'
  console.log('message', e.message); // 'The user aborted a request.'
});

Metadata

Metadata

Assignees

Labels

Feature:New PlatformTeam:CorePlatform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t//chore

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions