File write of blob (pdf type) content does not work for first few attempts

Running ionic2 app on One Plus Two Android 6.0.1

I need to generate pdf by merging some images and a watermark on each image. I am using canvas and pdfmake library to do the same. I could generate blob content using canvas and when I try to write blob using file write method of ionic-native/file it generates an empty file of 0 bytes. However, on second or third attempt onwards the same code works without any issue for same images and contents.

data - I know it is a valid blob data as on subsequent writes the same code it generates valid expected pdf.
directory path - I make sure directory is present with write access.
filename - test.pdf

this.file.writeFile(
  this.file.externalDataDirectory + "docs/pdf/",
  filename,
  data,
  {replace: true})
  .then((success) => {
    //I do not get control here till second or third attempt and restart app
  }).catch ((err) => {
    //I do not get control here either
});

I need to make sure file write of blob content works. Any suggestion will be helpful. Thanks.

This is the same issue - https://github.com/driftyco/ionic/issues/5638#event-629545213

Did you solve something?

I remember a dodgy issue with filewriter to be resolved by moving cordova.js in index.html to a higher location

Cant find it now due to network issues

What do you mean with “higher location”?

A bit higher up in indezx.html

Before some other script injection