React-native-fetch-blob: Invalid call promise-resolve on cancel download on Android

Created on 9 Nov 2016  路  8Comments  路  Source: wkh237/react-native-fetch-blob

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

android bug needs feedback needs investigation

All 8 comments

@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

rnfb 176

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NarendraSingh88 picture NarendraSingh88  路  3Comments

nicholasstephan picture nicholasstephan  路  3Comments

Draccan picture Draccan  路  3Comments

timsuchanek picture timsuchanek  路  4Comments

Jason0112 picture Jason0112  路  3Comments