const task = new RNFetchBlob
.config({
addAdnroidDownloads: {
useDownloadManager: true,
notification: true,
mediaScannable: true
},
timeout: 15000,
overwrite: startByte == 0,
fileCache : true,
path: filepath
})
.fetch('GET', link, headers)
return await task
.progress({ interval: 1000 }, (received, total) => {})
.then(function success(res) {
console.log(res.path())
}, function error(e) => {
console.log(e)
})
When I do task.cancel() success function triggeres.
This no happens on iOS but Android
I think this is bug, cuz when you cancel download action, should not resolve the promise
@raminious , thanks for reporting this issue. I'll look into it once I have time 馃憤
@wkh237 any news ?
@raminious , I'm pretty busy on my work these day .. if you can make a PR that'd be grateful 馃槃
@raminious , I've write a test for this issue but I could not reproduce the problem, could you help provide a working sample ? Thanks !
describe("Invalid promise.resolve call after task is canceled #176", (report, done) => {
let task = RNFetchBlob.fetch('GET', `${TEST_SERVER_URL}/public/22mb-dummy`)
task
.then(() => {
report(<Assert key="Promise should not resolved" expect={true} actual={false}/>);
})
.catch(() => {
report(<Assert key="Promise should not resolved" expect={true} actual={true}/>);
done()
});
task.progress((current, total) => {
report(<Info key={`${Math.floor(current/1024)}kb of ${Math.floor(total/1024)}kb`} uid="report"/>)
})
setTimeout(() => {
task.cancel();
}, 2000)
})
Here's what I saw

The network transmission is actually stopped after calling task.cancel(), I assume it's working fine?
Thank you @wkh237
Please run https://gist.github.com/raminious/17d3d3043a25e7acc57d0b82a969ba1e and do cancel task while downloading
@wkh237 May I hope you solve this bug ?
Thank you
@wkh237 Should I close this issue ? Would you like I share the gif clip of bug with you ?
Anything? I think I've the same