-
Notifications
You must be signed in to change notification settings - Fork 3k
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
AjaxObservable: complete subscribers on abort #4105
Conversation
Are you sure that the |
I tested it and the event was called when abort occurred due to sleeping my computer. |
I'm wondering if the behaviour differs between browsers and also if it differs depending on whether a connection is severed or cannot be established in the first place. In any case, if That's my two cents. I'll be interested to hear what others think about this. |
Interesting. it doesn't look like ng/http handles onAbort as well: https://github.com/angular/angular/blob/master/packages/common/http/src/xhr.ts so far I give a quick peek. What other libs does? if it's promise based, does it reject / or not handling, etcs? My immediate feeling is also this maybe error cases. |
I just attempted the same thing with http://output.jsbin.com/kelayinizo/quiet makes a request that takes 10 seconds to complete. If I sleep my computer in that time, here is what I find when I return:
|
I would think the |
xhr.onabort = () => { | ||
const { subscriber, progressSubscriber } = (<any>xhrLoad); | ||
if (progressSubscriber) { | ||
progressSubscriber.complete(); |
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.
complete
is a signal of successful completion. This isn't correct. If it's aborted, it did not complete successfully.
I can't approve this one, because I don't think it's the right approach. |
Thanks for the review @benlesh, I agree it should emit
In my testing, the observable does not emit anything, so I guess no. I'll update this PR to emit an error when the |
@benlesh This is still a bug. Could you reply to my previous comment? I'm happy to contribute |
Moved to #4251 |
Description:
It is possible for an XHR to be aborted externally, for example when the machine loses connectivity.
Currently, when the XHR is aborted in this way, the subscription remains.
In this case, I think we would want to complete the observable? Although it might also be useful to emit something to indicate it was aborted.