-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Closed
Labels
Feature:New PlatformTeam:CorePlatform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t//Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t//chore
Description
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, thefetch()promise rejects with anAbortError.
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//Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t//chore