-
Notifications
You must be signed in to change notification settings - Fork 728
Updated abort behavior #1141
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
Updated abort behavior #1141
Conversation
- Support for aborting a request with the promise api - Aborting a request will cause a RequestAbortedError - Normalized Connection class errors, now every error returned is wrapped by the client errors constructors
I have some general questions. I hope it's fine to ask here :) (or, is there a better channel for this?) Questions would be:
Thanks! :) |
@@ -23,6 +27,8 @@ class MockConnection extends Connection { | |||
process.nextTick(() => { | |||
if (!aborted) { | |||
callback(null, stream) | |||
} else { | |||
callback(new RequestAbortedError(), null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition !aborted
is in if
but its handler is in else
.
Better would be to put it together, and at the top, as a guard clause.
if (aborted) {
callback(new RequestAbortedError(), null)
return
}
callback(null, stream)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tomayto, tomahto :)
You can read it in both ways, if the operation has not been aborted, then continue, otherwise return a RequestAbortedError error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Read it, I can. Merge it, we can:)
@penge given that these questions are not related t this pr, I would kindly ask you to open an issue :) |
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-7.x 7.x
# Navigate to the new working tree
cd .worktrees/backport-7.x
# Create a new branch
git switch --create backport-1141-to-7.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick 27a8e2a9bf614224a96bf44293ace8a112ec8677
# Push it to GitHub
git push --set-upstream origin backport-1141-to-7.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-7.x Then, create a pull request where the |
* Updated abort behavior - Support for aborting a request with the promise api - Aborting a request will cause a RequestAbortedError - Normalized Connection class errors, now every error returned is wrapped by the client errors constructors * Updated test * Updated docs * Updated code generation script * Renamed test * Code coverage * Avoid calling twice transport.request
This pr contains a few feature and fixes:
Features
RequestAbortedError
constructor.Fixes
request.abort()
method, the callback style API will be called with aRequestAbortedError
, the promise will be rejected withRequestAbortedError
as well.ConnectionError
,TimeoutError
andRequestAbortedError
.Closes #1070