meteor / cordova-plugin-meteor-webapp

Cordova plugin that serves a Meteor web app through a local server and implements hot code push
MIT License
66 stars 74 forks source link

[Android] Error: Could not create download directory for large files in public directory #81

Closed brucejo75 closed 5 years ago

brucejo75 commented 5 years ago

I started seeing this error recently with Meteor v1.8.1. I also upgraded / added cordova-background-geolocation-lt@3.0.0 at this point.

Note: I am still investigating to make sure my app is not causing this... Thought I would get the issue entered, on the hope that someone else had this happen.

Environment

Meteor: v1.8.1 Android: v8.1.0 Cordova: 7.1.4

plugins:

Repro

  1. Create app with meteor build
  2. Deploy app on Android device and run it.

Result:

Error: Could not create download directory
    at :12848/plugins/cordova-plugin-meteor-webapp/www/webapp_local_server.js:51
    at Object.callbackFromNative (cordova.js:291)
    at <anonymous>:1:9
(anonymous) @ webapp.js:37
webapp.js:37 Error: timeout
    at :12848/plugins/cordova-plugin-meteor-webapp/www/webapp_local_server.js:51
    at Object.callbackFromNative (cordova.js:291)
    at <anonymous>:1:9
(anonymous) @ webapp.js:37

Initial HCP appears to not work. The app seems to work fine.

Workaround

It seems that shutting down the app and restarting will stop displaying the error and HCP works again.

brucejo75 commented 5 years ago

Another observation, my workaround is a little more complicated.

Workaround: While the app is running and connected to the server, update the server with new client code.

If I:

  1. shutdown the app
  2. update the server app with new client code.
  3. restart the app

Result: code does not update on the client app.

Going to try testing with a full build, instead of a dev run.

Nauzer commented 5 years ago

Do I understand it correctly that this issue is occurring for you on local development? Would be good to know if you can reproduce it with a PROD built server and client connecting to that as well.

brucejo75 commented 5 years ago

I also see the issue with a debug build running on my production server. I have not built a production version.

I have not had time to investigate further and I am building a workaround for my product that seems to work well enough.

After I get this next release out, I will try to isolate the issue more. I am suspicious of ordova-background-geolocation-lt@3.0.0 as that is the newest plugin I am using.

Nauzer commented 5 years ago

@brucejo75 Do I understand you right that you've made changes to your Cordova plugins on the server after the moment you initially built? If so the behaviour can be explained as HCP does not work when changes to your Cordova plugins are made. Don't think there is a workaround for that.

https://guide.meteor.com/mobile.html#updating-production-apps

brucejo75 commented 5 years ago

I am aware that changing the cordova plugins requires a rebuild of the client side app (or manipulation of the compatibility version).

To be clear - No, I am not changing the plugins between builds.

My workaround is to see if the client side app version is the same as the build version of the app. If they are the same I know that the latest client has not been HCP'ed to my app. So I wait 60 seconds and the do a location.reload. After 2-4 reloads, HCP completes. That seems to be working for me for now, until I can dig into it further.

PS: my build processes are such that my server version will always be a newer version than the app, so I always do a HCP first thing. (It is an issue I intend to fix, but for now I can take advantage of it)

brucejo75 commented 5 years ago

D'oh. I figured out the issue

I had a number of .apks sitting in my public directory. So Meteor was timing out downloading the .apks.

Moral of the story? Keep your public directory clean. Or at least minimized.

I would recommend that instead of outputting: Could not create download directory it might be better to display the size of the downloads that Meteor is dealing with. And then warn the user that the size should be minimized for a number of good reasons.

brucejo75 commented 5 years ago

Fixed by cleaning out public directory.