Skip to content

Inconsistent behavior when cancelling request with range header (ios vs. android) #28

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

Open
schumannd opened this issue May 4, 2018 · 5 comments

Comments

@schumannd
Copy link

schumannd commented May 4, 2018

react-native-cli: 2.0.1
react-native: 0.51.0
RNFetchBlob: 0.10.8

So when downloading something like so:

task = RNFetchBlob.config({
      path: dest,
      overwrite: false,
      IOSBackgroundTask: true,
      indicator: true,
    }).fetch('GET', url, {
      Range: `bytes=${size}-`,
    });
task.then(handleSuccess)
  .catch(handleError)

and then calling task.cancel(), I observe different behavior on iOS vs android.

iOS:
handleError(err) gets called where err.message === 'cancelled'. So this is nicely catcheable.

android:
handleSuccess(success) is called, where success has a HTTP code 206, which suggests that the range request was satisfied? It looks exactly like the response I get when the request finished successfully. Here is the content of respInfo, and it is the same whether I cancel the task or not:

headers: [
Accept-Ranges: "bytes"
Content-Length: "20177379"
Content-Range: "bytes 0-20177378/20177379"
Content-Type: "audio/mp3"
Date: "Fri, 04 May 2018 08:39:03 GMT"
ETag: ""...""
Last-Modified: "Tue, 12 Dec 2017 13:36:08 GMT"
Server: "AmazonS3"
x-amz-id-2: "..."
x-amz-request-id: "..."
]
redirects: ["https://s3-eu-west-1.amazonaws.com/.../efaaa2177b5f494390896e70d5444837.mp3"]
respType:  ""
rnfbEncode: "path"
state: "2"
status: 206
taskId: "jwy3rlqv5rkr1deb205f4p"
timeout: false

Any takes on why this happens?

@gigby
Copy link

gigby commented Oct 11, 2018

Ha-ha, funny situation:

(IS_ANDROID ? 'Canceled' : 'cancelled')

@schumannd
Copy link
Author

Can you elaborate?

@gigby
Copy link

gigby commented Oct 12, 2018

Yes. I just showed some funny aspect of the issue created by you. In Android returned error.msg === 'Canceled' but in iOS error.msg === 'cancelled'

@schumannd
Copy link
Author

If that is the case, I believe it should be fixed

@CapitanRedBeard
Copy link

Not really sure what @gigby is saying but the issue is on iOS task.cancel() throws a catchable error while Android it doesn't throw an error and succeeds normally. There is PR up here => #363

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants