Open MonasteryJohn opened 4 years ago
I think this issue might be related to using DownloadProgress() inside webkit.DownloadListener. Could you please make a sample project that shows how you're using it and ill take a look.
@tobydeh probably not related, because I get the same error as well, but I am not using webkit.DownloadListener
. For me the first download works as expected, but the second one fails with this error.
@MonasteryJohn @tobydeh upon further investigation it seems like this is happening because of worker terminations, after commenting out worker.terminate()
and moving worker import/constructor to DownloadProgress -> constructor (binding to this.worker
) it seems to be working as expected. I assume workers are supposed to be created once and reused. If I don't find further issues with this I will send a PR.
@nikoTM Thanks for taking the time to investigate the issue. I think you've hit the nail on the head - worker threads can't be reused after calling terminate()
I'm having trouble recreating this, can someone please create an example project demonstrating the issue?
I tried @nikoTM's solution and it works. Not a good solution but you can replace the file in node_modules/nativescript-download-progress with this file. download-progress.android.js.zip
Please can you try nativescript-download-progress@next
I am using fairly vanilla download code in my application. The first attempt during a given application session succeeds, but any attempts at downloading additional files results in an error. The error in the promise rejection is just a blank object
{}
but I was able to figure out that the actual exception message in theandroid-worker.js
isjava.io.File is not a constructor
. This error seems to come from the attempt atfs.File.fromPath(path)
.I tried to isolate whether this bug was in this library or in the nativescript core itself, but I can make the call to
fs.File.fromPath(path)
successfully from my code before calling the downloader. It works fine in my code, but the attempt from the downloader (in the same method) fails. This makes me to think it has something to do with how the worker interacts with the file system.Which platform(s) does your issue occur on?
Please, provide the following version numbers that your issue occurs with:
Please, tell us how to recreate the issue in as much detail as possible.
The code for the download is pretty much equal to the sample code, it looks like this
This
doDownload
function is being called on an event fromandroid.webkit.DownloadListener
like this: