Cap-go / capacitor-updater

Live update for capacitor apps
https://capgo.app
Mozilla Public License 2.0
471 stars 103 forks source link

bug: Updated bundle scripts does not run (index.js does not exists, there is no such file) #349

Closed brunoinds closed 1 month ago

brunoinds commented 1 month ago

Bug Report

Capacitor Version

πŸ’Š   Capacitor Doctor  πŸ’Š 

Latest Dependencies:

  @capacitor/cli: 5.7.4
  @capacitor/core: 5.7.4
  @capacitor/android: 5.7.4
  @capacitor/ios: 5.7.4

Installed Dependencies:

  @capacitor/cli: 5.7.0
  @capacitor/core: 5.4.1
  @capacitor/android: 5.4.1
  @capacitor/ios: 5.4.1

[success] iOS looking great! πŸ‘Œ
[success] Android looking great! πŸ‘Œ

Plugin Version

β”‚
●   πŸ’Š   Capgo Doctor  πŸ’Š
β”‚  
β”‚
●   OS: darwin Darwin Kernel Version 23.4.0: Fri Mar 15 00:12:41 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T8103
β”‚  
β”‚
●   Node: v18.16.0
β”‚  
β”‚
●   Installed Dependencies:
β”‚  
β”‚
●     @capgo/cli: 4.3.0
β”‚
●     @capgo/capacitor-updater: 5.8.9
β”‚
●  
β”‚  
βœ“   Latest Dependencies:
β”‚
●     @capgo/cli: 4.3.0
β”‚
●     @capgo/capacitor-updater: 5.8.9
β”‚
β—†  βœ… All dependencies are up to date

context(s)

ManualModel: true
AutoMode: false
CapgoCloud: false
OnPremise: false

Platform(s)

Current Behavior

  1. After sucessfully install the new bundle version (1.1.14), the browser console (WebKitView) throws the following error:

    Screenshot 2024-04-07 at 19 08 28
  2. Capacitor Updater fallback to the built in version sucessfully, because the CapacitorUpdater.notifyAppReady() is never called after 10s on the new version.

Expected Behavior

The new bundled zip version should run the js scripts well.

Code Reproduction

App built-in version: 1.1.12.

import { CapacitorUpdater } from '@capgo/capacitor-updater'
import { SplashScreen } from '@capacitor/splash-screen'
import { App } from '@capacitor/app'
let data = {version: ""}
CapacitorUpdater.notifyAppReady()
App.addListener('appStateChange', async(state) => {
     if (state.isActive) {
       data = await CapacitorUpdater.download({
       version: '1.1.14',
       url: 'https://maranatha.imedicineapp.com/api/app/native/bundles/1.1.14',
       })
     }
     if (!state.isActive && data.version !== "") {
       SplashScreen.show()
       try {
         await CapacitorUpdater.set(data)
       } catch (err) {
         console.log(err)
         SplashScreen.hide() // in case the set fail, otherwise the new app will have to hide it
       }
     }
 })

Other Technical Details

-> XCode Logs:

⚑️  [log] - {"bundles":[{"version":"1.1.14","size":"6670822","url":"https://maranatha.imedicineapp.com/api/app/native/bundles/1.1.14"}]}
⚑️  To Native ->  CapacitorUpdater download 132923118
✨  Capacitor-updater: Downloading Optional(https://maranatha.imedicineapp.com/api/app/native/bundles/1.1.14)
✨  Capacitor-updater: Storing info for bundle [ITvWJ8EeG3] { "id": "ITvWJ8EeG3", "version": "1.1.14", "downloaded": "2024-04-07T23:18:49.133Z", "checksum": "", "status": "downloading"}
✨  Capacitor-updater: Stats sent for download_0, version 1.1.14
✨  Capacitor-updater: Stats sent for download_10, version 1.1.14
✨  Capacitor-updater: Cannot found privateKey or sessionKey
✨  Capacitor-updater: Stats sent for download_80, version 1.1.14
✨  Capacitor-updater: Storing info for bundle [ITvWJ8EeG3] { "id": "ITvWJ8EeG3", "version": "1.1.14", "downloaded": "2024-04-07T23:18:54.948Z", "checksum": "b661cb90", "status": "pending"}
⚑️  TO JS {"checksum":"b661cb90","downloaded":"2024-04-07T23:18:54.948Z","status":"pending","id":"ITvWJ8EeG3","version":"1.1.14"}
✨  Capacitor-updater: Stats sent for download_complete, version 1.1.14
⚑️  TO JS {"isActive":false}
⚑️  TO JS {"isActive":true}
⚑️  To Native ->  SplashScreen show 132923119
⚑️  To Native ->  CapacitorUpdater set 132923120
✨  Capacitor-updater: Current bundle set to: /var/mobile/Containers/Data/Application/22D02258-3BD9-4E75-AEBE-5EC2E74AB10A/Library/NoCloud/ionic_built_snapshots/ITvWJ8EeG3
✨  Capacitor-updater: Setting status for bundle [ITvWJ8EeG3] to PENDING
✨  Capacitor-updater: Storing info for bundle [ITvWJ8EeG3] { "id": "ITvWJ8EeG3", "version": "1.1.14", "downloaded": "2024-04-07T23:18:54.948Z", "checksum": "b661cb90", "status": "pending"}
✨  Capacitor-updater: Set active bundle: ITvWJ8EeG3
✨  Capacitor-updater: semaphoreUp
✨  Capacitor-updater: semaphoreWait 0
✨  Capacitor-updater: Reloading ITvWJ8EeG3
✨  Capacitor-updater: Wait for 10000 ms, then check for notifyAppReady
⚑️  TO JS undefined
⚑️  To Native ->  SentryCapacitor addBreadcrumb 132923121
⚑️  TO JS undefined
⚑️  To Native ->  SentryCapacitor addBreadcrumb 132923122
⚑️  TO JS undefined
⚑️  [error] - {"message":"Network Error","name":"AxiosError","stack":"@capacitor://localhost/assets/index-c0e53703.js:12:64347\na@capacitor://localhost/assets/index-c0e53703.js:7:96846","config":{"transitional":{"silentJSONParsing":true,"forcedJSONParsing":true,"clarifyTimeoutError":false},"adapter":"xhr","transformRequest":[null],"transformResponse":[null],"timeout":0,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1,"maxBodyLength":-1,"env":{},"headers":{"Accept":"application/json, text/plain, */*","Authorization":"Bearer 209|ifOzjlLufxqTN1q1IZW3yvefYH66BJh1KDTYKWB18bbfe800","ngrok-skip-browser-warning":"true"},"params":{},"method":"get","url":"https://maranatha.imedicineapp.com/api/app/native/bundles"},"code":"ERR_NETWORK","status":null}
⚑️  To Native ->  SentryCapacitor fetchNativeSdkInfo 132923123
⚑️  TO JS {"version":"8.18.0","name":"sentry.cocoa.capacitor"}
⚑️  To Native ->  SentryCapacitor fetchNativeSdkInfo 132923124
⚑️  TO JS {"version":"8.18.0","name":"sentry.cocoa.capacitor"}
⚑️  To Native ->  SentryCapacitor fetchNativeDeviceContexts 132923125
⚑️  To Native ->  SentryCapacitor fetchNativeDeviceContexts 132923126
⚑️  TO JS {"context":{"os":{"version":"17.4.1","build":"21E236","rooted":false,"kernel_version":"Darwin Kernel Version 23.4.0: Fri Mar  8 23:31:19 PST 2024; root:xnu-10063.102.14~67\/RELEASE_ARM64_T8110","name":"iOS"},"app":{"app_build":"32","app_identifier":"com.im
⚑️  TO JS {"context":{"os":{"version":"17.4.1","build":"21E236","rooted":false,"kernel_version":"Darwin Kernel Version 23.4.0: Fri Mar  8 23:31:19 PST 2024; root:xnu-10063.102.14~67\/RELEASE_ARM64_T8110","name":"iOS"},"app":{"device_app_hash":"3edd48fa83345725145a4e
⚑️  [log] - onscript loading complete
⚑️  WebView loaded
✨  Capacitor-updater: Stats sent for set, version 1.1.14
⚑️  TO JS undefined
✨  Capacitor-updater: Current bundle is: { "id": "ITvWJ8EeG3", "version": "1.1.14", "downloaded": "2024-04-07T23:18:54.948Z", "checksum": "b661cb90", "status": "pending"}
✨  Capacitor-updater: notifyAppReady was not called, roll back current bundle: { "id": "ITvWJ8EeG3", "version": "1.1.14", "downloaded": "2024-04-07T23:18:54.948Z", "checksum": "b661cb90", "status": "pending"}
✨  Capacitor-updater: Did you forget to call 'notifyAppReady()' in your Capacitor App code?
✨  Capacitor-updater: Setting status for bundle [ITvWJ8EeG3] to ERROR
✨  Capacitor-updater: Storing info for bundle [ITvWJ8EeG3] { "id": "ITvWJ8EeG3", "version": "1.1.14", "downloaded": "2024-04-07T23:18:54.948Z", "checksum": "b661cb90", "status": "error"}
✨  Capacitor-updater: Resetting to builtin version
✨  Capacitor-updater: reset: false
✨  Capacitor-updater: Current bundle set to: builtin
✨  Capacitor-updater: semaphoreUp
✨  Capacitor-updater: semaphoreWait 0
✨  Capacitor-updater: Reloading builtin
✨  Capacitor-updater: Wait for 10000 ms, then check for notifyAppReady
✨  Capacitor-updater: Deleting failing bundle: { "id": "ITvWJ8EeG3", "version": "1.1.14", "downloaded": "2024-04-07T23:18:54.948Z", "checksum": "b661cb90", "status": "pending"}
✨  Capacitor-updater: Storing info for bundle [ITvWJ8EeG3] { "id": "ITvWJ8EeG3", "version": "1.1.14", "downloaded": "2024-04-07T23:18:54.948Z", "checksum": "b661cb90", "status": "deleted"}
✨  Capacitor-updater: bundle delete 1.1.14
✨  Capacitor-updater: Failed to delete failed bundle: { "id": "ITvWJ8EeG3", "version": "1.1.14", "downloaded": "2024-04-07T23:18:54.948Z", "checksum": "b661cb90", "status": "pending"}
⚑️  [log] - onscript loading complete
⚑️  WebView loaded
⚑️  To Native ->  SentryCapacitor initNativeSdk 66024580
⚑️  TO JS undefined
⚑️  To Native ->  SentryCapacitor addBreadcrumb 66024581
⚑️  TO JS undefined
⚑️  To Native ->  SentryCapacitor addBreadcrumb 66024582
⚑️  TO JS undefined
⚑️  [log] - {"appVersion":"1.1.12"}
⚑️  To Native ->  CapacitorUpdater notifyAppReady 66024587
✨  Capacitor-updater: semaphoreDown
✨  Capacitor-updater: Setting status for bundle [builtin] to SUCCESS
✨  Capacitor-updater: Not saving info for bundle [builtin] { "id": "builtin", "version": "builtin", "downloaded": "1970-01-01T00:00:00.000Z", "checksum": "", "status": "success"}
✨  Capacitor-updater: Fallback bundle is: { "id": "builtin", "version": "builtin", "downloaded": "1970-01-01T00:00:00.000Z", "checksum": "", "status": "success"}
✨  Capacitor-updater: Version successfully loaded: { "id": "builtin", "version": "builtin", "downloaded": "1970-01-01T00:00:00.000Z", "checksum": "", "status": "success"}
✨  Capacitor-updater: Current bundle loaded successfully. ['notifyAppReady()' was called] { "id": "builtin", "version": "builtin", "downloaded": "1970-01-01T00:00:00.000Z", "checksum": "", "status": "success"}
⚑️  TO JS {"bundle":{"version":"builtin","id":"builtin","downloaded":"1970-01-01T00:00:00.000Z","checksum":"","status":"success"}}
✨  Capacitor-updater: Stats sent for update_fail, version 1.1.14
✨  Capacitor-updater: Stats sent for reset, version builtin
✨  Capacitor-updater: Stats sent for delete, version 1.1.14

npm --version output: v9.5.1

node --version output: v18.16.0

pod --version output (iOS issues only): 1.15.2

riderx commented 1 month ago

Hey @brunoinds do your bundle 1.1.14 has also notifyAppReady called ? Have you done the zip with Capgo cli command as recommended ?