-
Notifications
You must be signed in to change notification settings - Fork 26.6k
fix(http): emit error on XMLHttpRequest abort event #40767
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
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.
@ItNoN thanks for the fix, the change looks good to me 👍
This change also looks related to #39807 and this PR will most likely require a rebase once #39807 lands (as they both update the same code).
I'm also adding @alxhub as a reviewer to this PR, since he participated in discussion in the original thread (#22324) and may have more context.
Thank you.
@AndrewKushnir, thank you for your quick response! Thanks! |
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.
I had some concerns originally, but I've convinced myself that this PR is good to go!
-
There is a question of whether
abort
events should be considered errors, or treated as a separateHttpEventType
. I was leaning towards the latter, but after looking at the triggers forabort
(beyond callingXmlHttpRequest.abort()
), I think there's no value in differentiating them for users. Indeed - grouping all possible errors together is very useful. -
This has nothing to do with the
abort()
we do when a requestObservable
is unsubscribed, because a. there is no possibility to emit values or errors after an unsubscription in general, and b. all event listeners are removed prior to thatabort()
anyway.
Therefore, I think this fix is good to go.
Before this change, when Google Chrome cancels a XMLHttpRequest, an Observable of the response never finishes. This happens, for example, when you put your computer to sleep or just press Ctrl+S to save the browser page. After this commit, if request is canceled or aborted an appropriate Observable will be completed with an error. Fixes angular#22324
9d922da
to
bda7e37
Compare
@AndrewKushnir, done. |
FYI, presubmits are successful for the changes in this PR, adding "merge" label. @ItNoN thanks for contributing to Angular! |
@ItNoN This PR unfortunately conflicts with the 11.2.x branch, so I can't merge it there. Can you open a separate PR against that branch directly? I'll go ahead and merge this to |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Fixes #22324
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: #22324
Before this change, when Google Chrome cancels a XMLHttpRequest, an Observable of the response never finishes. This happens, for example, when you put your computer to sleep or just press Ctrl+S to save the browser page.
What is the new behavior?
After this commit, if request is canceled or aborted an appropriate Observable will be completed with an error.
Does this PR introduce a breaking change?
Other information
I was thinking about a new HttpEventType that tracks the abort event, but it seems to me that if forces beyond your control have decided your request is no longer going to continue, it looks more like an error.
I couldn't find a way to reproduce this bug with JSONP. It appears JSONP request is not aborted.