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

AjaxObservable: does not error when aborted #4251

Closed
OliverJAsh opened this issue Oct 12, 2018 · 3 comments · Fixed by #6041
Closed

AjaxObservable: does not error when aborted #4251

OliverJAsh opened this issue Oct 12, 2018 · 3 comments · Fixed by #6041
Assignees

Comments

@OliverJAsh
Copy link
Contributor

Bug Report

Copied from #4105

Current Behavior
It is possible for an XHR to be aborted externally, for example when the machine loses connectivity, or when the machine is sent to sleep.

Currently, when the XHR is aborted in this way, the observable does not error and the subscription remains.

Reproduction

import { ajax } from 'rxjs/ajax'

ajax.get('https://httpbin.org/delay/10').subscribe();

Whilst request is pending, send machine to sleep.

When machine is woken, request is aborted, but observable did not error.

Expected behavior
In this case, I think we would want to error the observable? Although it might also be useful to emit something to indicate it was aborted.

Environment

  • Runtime: all envs that support AjaxObservable
  • RxJS version: 6.3.3

Possible Solution

Additional context/Screenshots

@kwonoj
Copy link
Member

kwonoj commented Oct 12, 2018

I guess error would be appropriate. (at least way I did is emitting error, like https://github.com/kwonoj/oxid/blob/master/src/adapters/xhr.ts#L233)

@olessavluk
Copy link

Also got this error after sleep/wake in Chrome, request was cancelled but Observable wasn't errored & wasn't completed, just stuck.

How this was handled in Axios - axios/axios#1399

@shenlin192
Copy link

It would be grateful if there is any news about this issue

olessavluk pushed a commit to olessavluk/rxjs that referenced this issue Oct 18, 2019
@benlesh benlesh self-assigned this Feb 22, 2021
benlesh added a commit to benlesh/rxjs that referenced this issue Feb 22, 2021
In the event of a network disconnection or other abort event, the returned observable will now error with an `AjaxError` and the message `"aborted"`.

Resolves ReactiveX#4251
benlesh added a commit to benlesh/rxjs that referenced this issue Feb 22, 2021
In the event of a network disconnection or other abort event, the returned observable will now error with an `AjaxError` and the message `"aborted"`.

Resolves ReactiveX#4251
benlesh added a commit that referenced this issue Feb 23, 2021
In the event of a network disconnection or other abort event, the returned observable will now error with an `AjaxError` and the message `"aborted"`.

Resolves #4251
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants