Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Error in plugin on File Transfer #148

Closed
northkode opened this issue Jul 6, 2016 · 11 comments
Closed

Error in plugin on File Transfer #148

northkode opened this issue Jul 6, 2016 · 11 comments
Labels

Comments

@northkode
Copy link

northkode commented Jul 6, 2016

getting an error when the plugin detects a new build and trys to download it

[Log] [CodePush] Downloading update
[Log] Error in Success callbackId: FileTransfer221795359 : TypeError: Attempted to assign to readonly property.

I'm assuming this has something to with the LocalPackage js class in the downloadSuccess call back code here

_this.currentFileTransfer = null;
fileEntry.file(function (file) {
NativeAppInfo.isFailedUpdate(_this.packageHash, function (installFailed) {
var localPackage = new LocalPackage();
localPackage.deploymentKey = _this.deploymentKey;
localPackage.description = _this.description;
localPackage.label = _this.label;
localPackage.appVersion = _this.appVersion;
localPackage.isMandatory = _this.isMandatory;
localPackage.packageHash = _this.packageHash;
localPackage.isFirstRun = false;
localPackage.failedInstall = installFailed;
localPackage.localPath = fileEntry.toInternalURL();
CodePushUtil.logMessage("Package download success: " + JSON.stringify(localPackage));
successCallback && successCallback(localPackage);
Sdk.reportStatusDownload(localPackage, localPackage.deploymentKey);
});

@lostintangent
Copy link
Member

lostintangent commented Jul 6, 2016

Could you share how you're calling sync? We haven't seen this error before, so I just want to make sure I know how your app is using the API so that I can try to repro it. Thanks!

@northkode
Copy link
Author

northkode commented Jul 6, 2016

this is my full code for syncing... its call on device ready.. and also application resume

 checkForUpdate() {
    codePush.getCurrentPackage(function (update) {
        if (!update) {
            this.alert("No updates have been installed");
            return;
        }

        // If the current app "session" represents the first time
        // this update has run, and it had a description provided
        // with it upon release, let's show it to the end user
        if (update.isFirstRun && update.description) {
            this.alert(update.description,function(){});
        }
    });
        codePush.sync(this.syncStatus.bind(this),{
        installmode:InstallMode.ON_NEXT_RESUME,
        minimumBackgroundDuration: 60 * 1,
        mandatoryInstallMode: InstallMode.ON_NEXT_RESUME,
        deploymentKey:(cordova.platformId == 'ios' ? '5TypsNkkTafw***' : '0K4XXkSJeIntOt***')
    });

}

syncStatus(status){
    switch (status) {
        case SyncStatus.DOWNLOADING_PACKAGE:
            this.alert("Downloading Update");
            break;
        case SyncStatus.INSTALLING_UPDATE:
            this.alert("Installing Update");
            break;
        case SyncStatus.UP_TO_DATE :
            this.alert("You are up to date");
            break;
        case SyncStatus.CHECKING_FOR_UPDATE:
            this.alert("Checking For update");
            break;
        case SyncStatus.IN_PROGRESS:
            this.alert("Syncing is in progress");
            break;
        case SyncStatus.ERROR:
            this.alert("There was an error");
            break;
    }
}

@lostintangent
Copy link
Member

lostintangent commented Jul 6, 2016

@northkode Hmm, I can't repro this unfortunately :/ Are you hitting this on Android and/or iOS? Emulator or device? Also, can you let us know which Cordova version and plugins you're using? Thanks!

@northkode
Copy link
Author

iOS simulator. Cordova 5.4.2, ios 3.9.2

we have alot of plugins running

android.support.v4 21.0.1 "Android Support v4"
code-push 1.9.0-beta "CodePushAcquisition"
com.nrswolf.cordova.push-notifications-status 1.0.0 "Push Notifications Status"
com.telerik.plugins.nativepagetransitions 0.5.6 "Native Page Transitions"
com.telerik.plugins.wkwebview 0.6.4 "WKWebView Polyfill"
cordova-fabric-plugin 1.0.7 "cordova-fabric-plugin"
cordova-plugin-actionsheet 2.2.2 "ActionSheet"
cordova-plugin-app-version 0.1.8 "AppVersion"
cordova-plugin-appavailability 0.4.2 "AppAvailability"
cordova-plugin-camera 2.2.0 "Camera"
cordova-plugin-code-push 1.8.2-beta "CodePush"
cordova-plugin-compat 1.0.0 "Compat"
cordova-plugin-crosswalk-webview 1.4.0 "Crosswalk WebView Engine"
cordova-plugin-customurlscheme 4.2.0 "Custom URL scheme"
cordova-plugin-datepicker 0.9.2 "DatePicker"
cordova-plugin-device 1.1.2 "Device"
cordova-plugin-dialogs 1.2.0 "Notification"
cordova-plugin-facebook4 1.4.1 "Facebook Connect"
cordova-plugin-file 3.0.0 "File"
cordova-plugin-file-transfer 1.5.1 "File Transfer"
cordova-plugin-image-picker 1.0.8 "ImagePicker"
cordova-plugin-inappbrowser 1.4.0 "InAppBrowser"
cordova-plugin-ios-longpress-fix 1.1.0 "iOS LongPress Fix"
cordova-plugin-keyboard 1.1.2 "Keyboard"
cordova-plugin-media 1.0.1 "Media"
cordova-plugin-network-information 1.2.1 "Network Information"
cordova-plugin-screen-orientation 1.4.0 "Screen Orientation"
cordova-plugin-splashscreen 2.1.0 "Splashscreen"
cordova-plugin-statusbar 1.0.1 "StatusBar"
cordova-plugin-webserver 1.0.3 "CordovaWebServer"
cordova-plugin-whitelist 1.0.0 "Whitelist"
cordova-plugin-x-toast 2.5.1 "Toast"
cordova-plugin-zip 3.1.0 "cordova-plugin-zip"
cordova.custom.plugins.exitapp 1.0.0 "ExitApp"
onesignal-cordova-plugin 1.12.3 "OneSignal Push Notifications"

still dont see how this would effect the read only property of the callback tho..

@lostintangent
Copy link
Member

lostintangent commented Jul 6, 2016

@northkode Are you using an iOS 8.* simulator by any chance? It seems like there was a known issue with the iOS WebView on iOS 8, but I still can't repro this, even with an iOS 8.1 or 8.4 simulator image.

All of the props in the code snippet you mentioned are simply dynamically set data properties (here is the base class which "defines" them in TypeScript), and we aren't explicitly setting any of them to write only, so I asked about the platform and plugin versions because we've seen numerous interop issues with plugins that modify the runtime in a way that can affect odd / fundamental behaviors of our plugin.

@northkode
Copy link
Author

Unfortunately this was ios 9 simulator.
I tried to edit the remote package js file to see about debugging it further but every time I cordova run ios it overwrites my file.

Is there a way around this without installing a local plug in instead? I don't get why cordova overwrites the files when I edit the bin sec directly

@northkode
Copy link
Author

I just tried this on android and i am getting a similar error

Error in Success callbackId: FileTransfer1211465793 : TypeError: Cannot assign to read only property 'persistent' of files
FileSystem.js:123 Uncaught (in promise) TypeError: Cannot assign to read only property 'persistent' of files
at new module.exports (file:///android_asset/www/js/core/FileSystem.js:123:32)
at win (file:///android_asset/www/plugins/cordova-plugin-file-transfer/www/FileTransfer.js:217:32)
at Object.cordova.callbackFromNative (file:///android_asset/www/cordova.js:291:58)
at processMessage (file:///android_asset/www/cordova.js:1079:17)
at processMessages (file:///android_asset/www/cordova.js:1102:9)

@northkode
Copy link
Author

OK i think i figured out the issue.

One of my plugins had overwrittent the FileSystem method on window and it was expecting an object of options instead of a string of persistent or temporary which is the readonly issue.

Thanks for looking into it aswell!!

@lostintangent
Copy link
Member

@northkode Awesome! I'm glad you figured it out. We see a lot of these unexpected interop issues, which is why I'm always curious to get a list of plugins, even when it doesn't make a lot of sense that they could be related :) Thanks for getting back to us.

@northkode
Copy link
Author

Sorry to follow up on a closed ticket... but just curious if you have a work around for the wkwebview local host server? is there somewhere you can point me to changing the url of the index page to a relative path vs a file:// path after i install an update on the ios? its breaking my build

http://localhost:12344/file:///Users/kylejeske/Library/Developer/CoreSimulator/Devices/FCA8172D-2D8D-41BA-8EA3-D068BCCD0BC4/data/Containers/Data/Application/B5C9BD6A-A4F3-473D-8FE7-190410F4CA4C/Library/NoCloud/codepush/deploy/versions/8b3bbfe70db499c511e75ad7eef0299c064b2fb2785ce05ae6fcf805abaa6f4a/www/index.html

you can see that your plugin changes the html path to a version hash but its appended with file:/// would be better to have it be a relative path of the application

@richardhuaaa
Copy link
Contributor

For anyone else looking at this thread, discussion about cordova-plugin-wkwebview-engine-localhost can be found at #134!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants