-
Notifications
You must be signed in to change notification settings - Fork 787
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
Problem with canceling the request #140
Comments
Try to put in request |
I have an issue maybe is a bug, I don't know. When I request a cancel the promise of success is triggered.
|
Same issue on Android as @ithustle explained, and i do not know if the issue also happens on iOS. |
@HasanAlyazidi only on Android. On IOS is working propertly |
I managed to solve it with this workaround ...
this.isCancelled = false; // <-- step 1 (needed if you want to retry downloading)
this.task = config(options).fetch('GET', url);
this.task.progress((received, total) => {
let progress_value = received / total;
this.setState({ progress_value });
});
this.task.then((res) => {
if (this.isCancelled) return; // <-- step 2
// save to db/redux, etc...
})
.catch(err => console.log(err))
...
_cancelDownload() {
this.isCancelled = true; // <-- step 3
this.task.cancel((err, taskId) => {
// Handle cancelling
});
} |
Same problem here |
Experiencing the same issue. |
Same issue as @ithustle explained. And @HasanAlyazidi 's workaround may face the problem when the download is canceled because of network error, not canceled by hand. |
I think this PR #381 fixes it. |
I do not why, but on iOS canceling the request is quite unreliable. Running on simulator, it happens pretty often that cancel method call is ignored. |
Specs:
"react-native": "0.55.4",
"rn-fetch-blob": "0.10.12",
Hello guys :)
So I have a problem with canceling request. I'm trying to download some huge apk file (more than 400 MB) and I want to give user ability to cancel the download process.
So I'm creating the request in this way:
Then, when I call:
There is error that says that "cancel" is not a function.
What I'm doing wrong? :)
BTW: Beside this issue, great library!
The text was updated successfully, but these errors were encountered: