-
Notifications
You must be signed in to change notification settings - Fork 61
feat: special handling for AbortError
#442
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
Conversation
Since Update: after toying a bit with it, there's a couple of options on the table -- The test relevant to the handling of request cancellation could be skipped for Node versions that don't support (typeof AbortController !== 'undefined' ? it : it.skip)('test description', () => { ... }) in which case the cancellation test would essentially only run in the Node v16 case of the matrix; It's also possible to come up with a proper mock that would emulate the behaviour of The latter option allows to preserve the test coverage rating in all environments, otherwise the I'm going to dig around a bit more into what that mock would look like. |
I ended up coming up with a mock that isn't terrible, although there's definitely room for improvement. It does allow the assertion that the error that is thrown via the An interesting option here would be to introduce some sort of Input welcome on what is preferred if applicable! |
Hi @mcataford ! We recently dropped support for any version for NodeJS < 14 Are you still interested in updating this and getting this completed |
Absolutely! I'll take a look today and get this in order! 🚀 |
In principle, there's no update needed here since
✔️ Rebased so the branch is up to date; |
test: coverage for AbortError handling docs: mention AbortError behaviour test: mocking controller/signal
@wolfy1339 Noticed that this was out-of-date v. Thank you for the review and follow-up! 🎉 Looking forward to seeing this merged! 🚀 |
🎉 This PR is included in version 6.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Description
This aims to address #362 and adds specific handling for
AbortError
being thrown during a request. In the present state of things, if a user were to pass anAbortSignal
viaoptions.request.signal
, the resulting error gets lumped in with a genericRequestError
and the fact that the request was aborted is obscured.With the present changes, the
AbortError
is bubbled up (similarly to howRequestError
instances thrown byfetch
are) so that the user can handle it however they want.I'm more than open to input if you have a better vision for what should be included in the error that's rethrown (i.e. if it should be wrapped the same way the catchall
RequestError
is) if simply bubbling up theAbortError
isn't enough. Since request cancellation is intentional, I would expect that as long as whoever callsrequest(...)
can know and handle it properly, not much more is needed.This also tosses in a sample test case to cover this behaviour.
View rendered README.md