Skip to content
This repository has been archived by the owner on Mar 16, 2019. It is now read-only.

How to cancel the HTTPS Request Download #268

Open
leo403771872 opened this issue Feb 16, 2017 · 13 comments
Open

How to cancel the HTTPS Request Download #268

leo403771872 opened this issue Feb 16, 2017 · 13 comments

Comments

@leo403771872
Copy link

It's ok to stop HTTP Request Download By the function cancel().
However I use the function cancel() to stop a HTTPS Download but crash.
Log is RCTFatalException: Unhandled JS Exception: u.cancel is not a function. (In 'u.cancel()', 'u.cancel' is undefined).
Is this function cann't stop Https Download?

@wkh237
Copy link
Owner

wkh237 commented Feb 16, 2017

@leo403771872 , does it happens on both IOS and Android?

@leo403771872
Copy link
Author

@wkh237 Yes, both iOS and Android happen. Log says it' not a function

@wkh237
Copy link
Owner

wkh237 commented Feb 17, 2017

Could you provide a code snippet about how you use it? Please also refer to #256 and try if the solution works for you 👍

@leo403771872
Copy link
Author

@wkh237 I have seen #256 . Our code is almost the same. It's ok to stop Http download, but not in Https

wkh237 added a commit that referenced this issue Feb 17, 2017
@wkh237
Copy link
Owner

wkh237 commented Feb 18, 2017

I can replicate this issue on my end now, the cause is that when calling task.cancel() native context does not add the session to request table yet. I've applied a fix at 0b6beae.

Please try to upgrade your package from the branch

$ npm install --save github:wkh237/react-native-fetch-blob-package#0.10.3-fix-268

@Pedneri1
Copy link

Pedneri1 commented Mar 2, 2017

I have exactly the same code, as shown in #256, upgraded to the fix-268 but still get the error
"cancel is not a function". Tried to increase the time of the backoff but it didn't work.

@Jacse
Copy link
Contributor

Jacse commented Jul 1, 2017

Still experiencing this on react-native-fetch-blob@0.10.6

@wkh237
Copy link
Owner

wkh237 commented Jul 9, 2017

Okay, I can confirm that on Android when either fileCache or path is set to config this problem happens. Basically, the task is canceled but it invokes then instead of catch.

@wkh237
Copy link
Owner

wkh237 commented Jul 9, 2017

I have pushed a fixed version to branch issue-268 please upgrade your package from the branch if anyone would like to verify it, thanks 💯

@kesha-antonov
Copy link

kesha-antonov commented Jul 13, 2017

@wkh237

Hello!

Tried branch issue-268
It's working 👍

If I use "useDownloadManager" it does not. And progress doesn't work with "useDownloadManager"

@wkh237
Copy link
Owner

wkh237 commented Jul 14, 2017

@kesha-antonov , thanks for verifying this for us, will look into the issue 👍

@kaylabranson
Copy link

Still never going to catch with fileCache

@slayer49
Copy link

slayer49 commented Sep 14, 2017

Still getting task.cancel is not a function using 0.10.9 branch installed from github. I am using eventChannel from redux-saga which requires a function callback to end the process.

EDIT: My issue was not related to this issue, it was eventChannel using task.cancel when task was was already completed. I updated to check if the cancel function exists first:

danielsuo added a commit to danielsuo/react-native-fetch-blob that referenced this issue Feb 13, 2018
* upstream/0.10.9:
  Fixed problem with type casting (wkh237#513)
  My proposed 0.10.9 changes (wkh237#489)
  wkh237#268 Cancelled task should not trigger `then` promise function
  Add ability to cancel android DownloadManager fetches (wkh237#502)
  Fix iOS initialization race condition (wkh237#499)
  prevent UIApplication methods from being called on background thread (wkh237#486)
  Implemenet fs.hash() -- wkh237#439 "Feature: Calculate file hash" (wkh237#476)
  I forgot one error string for the Android readFile() method (wkh237#475)
  Fix for wkh237#467 (wkh237#472)
  Fix for issue wkh237#468, wkh237#461, wkh237#460 and minor cleanup (wkh237#469)
campsafari pushed a commit to exozet/react-native-fetch-blob that referenced this issue Apr 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants