Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hotcodepush app on Ionic 4 fails to load the updates #25

Closed
DanishaRegil opened this issue Jan 7, 2020 · 9 comments
Closed

hotcodepush app on Ionic 4 fails to load the updates #25

DanishaRegil opened this issue Jan 7, 2020 · 9 comments

Comments

@DanishaRegil
Copy link

Post placing the updated build in the remote url and relaunching of app, blanks out

@DanishaRegil
Copy link
Author

On taking a deeper look into the issue was able to see, only few of the build files where download before which the loader worker has stopped.

Any idea on what would have caused this interruption

image

@ralscha
Copy link
Owner

ralscha commented Jan 7, 2020

Check the chcp.manifest file. The plugin only downloads files that are listed in that file.

Be aware that this cordova plugin is no longer supported:
nordnet/cordova-hot-code-push#371

@DanishaRegil
Copy link
Author

Though the chcp.manifest has got the list of all build files, only 5 or 6 files get downloaded each time, any clue on it

@ralscha
Copy link
Owner

ralscha commented Jan 8, 2020

One last thing I would check is if the hash in the chcp.manifest file has changed. The plugin downloads the file only when the hash is different.

@DanishaRegil
Copy link
Author

Ya that explains, so Only If the hash file changes in chp.manifest, the plugin downloads,
but as per the logs, post downloads the app is getting served from external location: /data/user/0/io.ionic.starter/files/cordova-hot-code-push-plugin/2020.01.07-04.17.30/www/index.html instead of the previous http://localhost, If that is case the new location might have only the updated files and not all the files right.

Correct me if my understanding is wrong or how to address it

as when launched from external location post update I get all 404 errors
below is the code snippet

2020-01-07 06:28:49.046 27495-27610/io.ionic.starter D/CHCP: Loading file: http:///updates/cordova_plugins.js
2020-01-07 06:28:50.835 27495-27610/io.ionic.starter D/CHCP: Loading file: http://
/updates/main-es2015.js
2020-01-07 06:28:52.796 27495-27610/io.ionic.starter D/CHCP: Loading file: http:///updates/main-es2015.js.map
2020-01-07 06:28:54.427 27495-27610/io.ionic.starter D/CHCP: Loading file: http://
/updates/main-es5.js
2020-01-07 06:28:55.295 27495-27610/io.ionic.starter D/CHCP: Loading file: http://**********/updates/main-es5.js.map
2020-01-07 06:28:55.977 27495-27610/io.ionic.starter D/CHCP: Loader worker has finished
2020-01-07 06:28:55.978 27495-27610/io.ionic.starter D/CHCP: Update is ready for installation: 2020.01.07-04.17.30
2020-01-07 06:28:55.986 27495-27495/io.ionic.starter D/SystemWebChromeClient: http://localhost/main-es2015.js: Line 549 : fetched Update ***
2020-01-07 06:28:55.986 27495-27495/io.ionic.starter I/chromium: [INFO:CONSOLE(549)] "fetched Update ***", source: http://localhost/main-es2015.js (549)
2020-01-07 06:28:55.995 27495-27495/io.ionic.starter D/SystemWebChromeClient: http://localhost/main-es2015.js: Line 552 : UpdateAvailableForInstallation ***
2020-01-07 06:28:55.995 27495-27495/io.ionic.starter I/chromium: [INFO:CONSOLE(552)] "UpdateAvailableForInstallation ***", source: http://localhost/main-es2015.js (552)
2020-01-07 06:28:55.996 27495-27599/io.ionic.starter D/CHCP: Dispatching Before install event
2020-01-07 06:28:56.606 27495-27633/io.ionic.starter D/CHCP: Update is installed
2020-01-07 06:28:56.612 27495-27495/io.ionic.starter D/CordovaWebViewImpl: >>> loadUrl(file:///data/user/0/io.ionic.starter/files/cordova-hot-code-push-plugin/2020.01.07-04.17.30/www/index.html)
2020-01-07 06:28:56.614 27495-27495/io.ionic.starter D/CHCP: Loading external page: /data/user/0/io.ionic.starter/files/cordova-hot-code-push-plugin/2020.01.07-04.17.30/www/index.html

image

initializeApp() {
this.platform.ready().then(() => {
this.statusBar.styleDefault();
this.splashScreen.hide();
window["thisRef"] = this;
this.fetchUpdate();
});
}

fetchUpdate() {
const options = {
'config-file': '************/updates/chcp.json'
};
this.chcp.fetchUpdate(options).
then(
(value:any)=>{
this.chcp.isUpdateAvailableForInstallation().
then((value:any)=>{
this.chcp.installUpdate().then((res:any)=>{
console.log(res);
}
)
})

    },(error:any)=>
    {
      console.log("e =>"+error)
    });

}

@ralscha
Copy link
Owner

ralscha commented Jan 8, 2020

I have no clue. Very strange that the url changes. I used this plugin for about 2 years before they deprecated it and I removed it from my application.

My code looked very similar. The only difference, in my application I did not call isUpdateAvailableForInstallation.

fetchUpdate() {
      const options = {
        'config-file': ENV.UPDATE_URL
      };
      chcp.fetchUpdate(this.updateCallback.bind(this), options);
}

  updateCallback(error, data) {
    if (!error) {
      chcp.installUpdate(error => {
        if (error) {
          console.log(error);
        }
      });
    } 
  }

@ralscha
Copy link
Owner

ralscha commented Jan 9, 2020

I don't use hot updates anymore. I switched to Capacitor and I didn't find a self hosted solution that works with Capacitor.

For Cordova application I would check out Microsoft's CodePush.
Ionic Appflow also has a solution.

And this looks interesting: IonPush

@DanishaRegil
Copy link
Author

Ya agree, Microsoft Code Push works absolutely fine, but im trying to work around without Microsoft.

But with upgrading of Ionic 4 even similar issue was reported in the Microsoft code push and was later fixed.
microsoft/cordova-plugin-code-push#486
microsoft/cordova-plugin-code-push@832d56c

@ralscha
Copy link
Owner

ralscha commented Jan 9, 2020

I see, there was a problem. Too bad that they abandoned the cordova-hot-code-push project. Would be great to have a self-hosted solution.

@ralscha ralscha closed this as completed Feb 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants