React-native-fetch-blob: How to cancel the HTTPS Request Download

Created on 16 Feb 2017  路  13Comments  路  Source: wkh237/react-native-fetch-blob

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?

android bug needs verification

Most helpful comment

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.

All 13 comments

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

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

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

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

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

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.

Still experiencing this on [email protected]

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.

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 馃挴

@wkh237

Hello!

Tried branch issue-268
It's working 馃憤

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

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

Still never going to catch with fileCache

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:

Was this page helpful?
0 / 5 - 0 ratings