Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core HTTP fetch service doesn't return AbortError #51406

Closed
lukasolson opened this issue Nov 21, 2019 · 6 comments · Fixed by #97086
Closed

Core HTTP fetch service doesn't return AbortError #51406

lukasolson opened this issue Nov 21, 2019 · 6 comments · Fixed by #97086
Assignees
Labels
chore Feature:New Platform Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc

Comments

@lukasolson
Copy link
Member

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.'
});
@lukasolson lukasolson added bug Fixes for quality problems that affect the customer experience Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc Feature:New Platform labels Nov 21, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-platform (Team:Platform)

@eliperelman eliperelman self-assigned this Nov 22, 2019
@mshustov
Copy link
Contributor

mshustov commented Jan 8, 2020

the problem seems to be solved in https://github.com/elastic/kibana/pull/53766/files/5ad68ea3f314aaec889c85805e4e77e9d0236fc6#diff-fc8d4853dbfb5a62d938e7155ee7d372
although there are no tests. let's add tests for abortable requests as a part of the current issue

@lukasolson
Copy link
Member Author

Fixed by #53766.

@mshustov
Copy link
Contributor

requires at least minimal test coverage

@mshustov mshustov reopened this Jan 22, 2020
@joshdover joshdover added chore and removed bug Fixes for quality problems that affect the customer experience labels Jan 28, 2020
@joshdover
Copy link
Contributor

Marking as chore since this is just writing tests now

@lukasolson
Copy link
Member Author

Please keep this in mind when creating tests: #56244

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Feature:New Platform Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants