mapiacompany / capacitor-codepush

Capacitor plugin for CodePush
http://appcenter.ms
Other
152 stars 64 forks source link

The file “currentPackage.json” couldn’t be opened because there is no such file #21

Open priyanga-ganapathi-zoomrx opened 3 years ago

priyanga-ganapathi-zoomrx commented 3 years ago

Description

I created a capacitor project, installed the plugins, and configured the deployment key. From the javascript layer, I invoked the sync() function. I'm getting the following error and the application gets crashed at the end.

ERROR MESSAGE:  {"message":"The file “currentPackage.json” couldn’t be opened because there is no such file.","errorMessage":"The file “currentPackage.json” couldn’t be opened because there is no such file."}
⚡️  [error] - {"message":"The file “currentPackage.json” couldn’t be opened because there is no such file.","errorMessage":"The file “currentPackage.json” couldn’t be opened because there is no such file."}
⚡️  To Native ->  CodePush getAppVersion 52875057
⚡️  TO JS {"value":"1.0"}
⚡️  To Native ->  CodePush getBinaryHash 52875058
ERROR MESSAGE:  {"errorMessage":"An error occurred when trying to get the hash of the binary contents. ","message":"An error occurred when trying to get the hash of the binary contents. "}
⚡️  To Native ->  CodePush getAppVersion 52875059
⚡️  [error] - {"errorMessage":"An error occurred when trying to get the hash of the binary contents. ","message":"An error occurred when trying to get the hash of the binary contents. "}
⚡️  [error] - [CodePush] Could not get binary hash.Error: Could not get binary hash. 
⚡️  TO JS {"value":"1.0"}
⚡️  [log] - [CodePush] Checking for update.
⚡️  To Native ->  Http request 52875060
⚡️  TO JS {"headers":{"Strict-Transport-Security":"max-age=15724800; includeSubDomains","Access-Control-Allow-Origin":"*","Vary":"Accept-Encoding","Content-Type":"application\/json; charset=utf-8","Content-Encoding":"gzip","access-control-allow-methods":"GET","acces
⚡️  To Native ->  CodePush isFailedUpdate 52875061
⚡️  TO JS {"value":0}
⚡️  [log] - [CodePush] An update is available. {"isDownloading":false,"appVersion":"1.0","deploymentKey":"svqcsCjsJhESC0ZmUXYe3nym2mRede7REmeCX","downloadUrl":"https://codepushupdates.azureedge.net/storagev2/5eXOhadabwEgZHnQjkwnW_JlARRK0c894bb4-6419-4a7e-ae5e-6c01025b63ae","isMandatory":false,"label":"v3","packageHash":"048f5e1ca9db0d66c3a9b56c36501db8ab9738a3c27f1002b424cb541bcacca9","packageSize":22793,"failedInstall":0}
⚡️  [log] - [CodePush] Downloading update
⚡️  To Native ->  Filesystem getUri 52875062
⚡️  TO JS {"uri":"file:\/\/\/Users\/\/Library\/Developer\/CoreSimulator\/Devices\/AC8BE0AE-1B17-4507-9CD5-E6098D4B144F\/data\/Containers\/Data\/Application\/E839E370-8FF2-44E8-B97B-0CD4B9EC4EBA\/Documents\/codepush\/download\/update.zip"}
⚡️  To Native ->  Filesystem stat 52875063
ERROR MESSAGE:  {"message":"The file “download” couldn’t be opened because there is no such file.","errorMessage":"The file “download” couldn’t be opened because there is no such file."}
⚡️  [error] - {"message":"The file “download” couldn’t be opened because there is no such file.","errorMessage":"The file “download” couldn’t be opened because there is no such file."}
⚡️  To Native ->  Filesystem mkdir 52875064
⚡️  TO JS undefined
⚡️  To Native ->  Filesystem stat 52875065
ERROR MESSAGE:  {"errorMessage":"The file “update.zip” couldn’t be opened because there is no such file.","message":"The file “update.zip” couldn’t be opened because there is no such file."}
⚡️  [error] - {"errorMessage":"The file “update.zip” couldn’t be opened because there is no such file.","message":"The file “update.zip” couldn’t be opened because there is no such file."}
⚡️  To Native ->  Http downloadFile 52875066
⚡️  TO JS {"status":200,"url":"https:\/\/codepush.appcenter.ms\/v0.1\/public\/codepush\/report_status\/deploy","data":"OK","headers":{"access-control-allow-credentials":"false","Strict-Transport-Security":"max-age=15724800; includeSubDomains","Content-Type":"text\/p
⚡️  To Native ->  CodePush reportSucceeded 52875067
⚡️  [log] - [CodePush] Reported status: {"status":0,"appVersion":"1.0","deploymentKey":"svqcsCjsJhESC0ZmUXYe3nym2mRede7REmeCX","lastVersionLabelOrAppVersion":null,"lastVersionDeploymentKey":null}
⚡️  TO JS undefined
File Dest file:///Users/Library/Developer/CoreSimulator/Devices/AC8BE0AE-1B17-4507-9CD5-E6098D4B144F/data/Containers/Data/Application/E839E370-8FF2-44E8-B97B-0CD4B9EC4EBA/Documents/codepush/download/update.zip
⚡️  TO JS {"path":"file:\/\/\/Users/Library\/Developer\/CoreSimulator\/Devices\/AC8BE0AE-1B17-4507-9CD5-E6098D4B144F\/data\/Containers\/Data\/Application\/E839E370-8FF2-44E8-B97B-0CD4B9EC4EBA\/Documents\/codepush\/download\/update.zip"}
Downloaded file file:///Users/Library/Developer/CoreSimulator/Devices/AC8BE0AE-1B17-4507-9CD5-E6098D4B144F/data/Containers/Data/Application/E839E370-8FF2-44E8-B97B-0CD4B9EC4EBA/tmp/CFNetworkDownload_BknJec.tmp
⚡️  To Native ->  CodePush isFailedUpdate 52875068
⚡️  TO JS {"value":0}
⚡️  [log] - [CodePush] Package download success: {"deploymentKey":"svqcsCjsJhESC0ZmUXYe3nym2mRede7REmeCX","label":"v3","appVersion":"1.0","isMandatory":false,"packageHash":"048f5e1ca9db0d66c3a9b56c36501db8ab9738a3c27f1002b424cb541bcacca9","isFirstRun":false,"failedInstall":0,"localPath":"file:///Users/Library/Developer/CoreSimulator/Devices/AC8BE0AE-1B17-4507-9CD5-E6098D4B144F/data/Containers/Data/Application/E839E370-8FF2-44E8-B97B-0CD4B9EC4EBA/Documents/codepush/download/update.zip"}
⚡️  [log] - [CodePush] Installing update
⚡️  To Native ->  Filesystem stat 52875069
⚡️  To Native ->  Http request 52875070
ERROR MESSAGE:  {"message":"The file “unzipped” couldn’t be opened because there is no such file.","errorMessage":"The file “unzipped” couldn’t be opened because there is no such file."}
⚡️  [error] - {"message":"The file “unzipped” couldn’t be opened because there is no such file.","errorMessage":"The file “unzipped” couldn’t be opened because there is no such file."}
⚡️  To Native ->  Filesystem mkdir 52875071
⚡️  TO JS undefined
⚡️  To Native ->  Filesystem getUri 52875072
⚡️  TO JS {"uri":"file:\/\/\/Users\/Library\/Developer\/CoreSimulator\/Devices\/AC8BE0AE-1B17-4507-9CD5-E6098D4B144F\/data\/Containers\/Data\/Application\/E839E370-8FF2-44E8-B97B-0CD4B9EC4EBA\/Documents\/codepush\/download\/unzipped\/"}
⚡️  To Native ->  CodePush unzip 52875073
⚡️  TO JS undefined
⚡️  To Native ->  Filesystem stat 52875074
ERROR MESSAGE:  {"message":"The file “hotcodepush.json” couldn’t be opened because there is no such file.","errorMessage":"The file “hotcodepush.json” couldn’t be opened because there is no such file."}
⚡️  To Native ->  ⚡️  [error] - {"message":"The file “hotcodepush.json” couldn’t be opened because there is no such file.","errorMessage":"The file “hotcodepush.json” couldn’t be opened because there is no such file."}
Filesystem stat 52875075
ERROR MESSAGE:  {"errorMessage":"The file “versions” couldn’t be opened because there is no such file.","message":"The file “versions” couldn’t be opened because there is no such file."}
⚡️  To Native ->  Filesystem mkdir 52875076
⚡️  [error] - {"errorMessage":"The file “versions” couldn’t be opened because there is no such file.","message":"The file “versions” couldn’t be opened because there is no such file."}
⚡️  TO JS undefined
⚡️  To Native ->  Filesystem stat 52875077
ERROR MESSAGE:  {"errorMessage":"The file “048f5e1ca9db0d66c3a9b56c36501db8ab9738a3c27f1002b424cb541bcacca9” couldn’t be opened because there is no such file.","message":"The file “048f5e1ca9db0d66c3a9b56c36501db8ab9738a3c27f1002b424cb541bcacca9” couldn’t be opened because there is no such file."}
⚡️  [error] - {"errorMessage":"The file “048f5e1ca9db0d66c3a9b56c36501db8ab9738a3c27f1002b424cb541bcacca9” couldn’t be opened because there is no such file.","message":"The file “048f5e1ca9db0d66c3a9b56c36501db8ab9738a3c27f1002b424cb541bcacca9” couldn’t be opened because there is no such file."}
⚡️  To Native ->  Filesystem copy 52875078
⚡️  TO JS undefined
⚡️  To Native ->  CodePush getPublicKey 52875079
⚡️  [log] - [CodePush] Applying full update
2021-03-12 10:56:22.857960+0530 App[63556:7336508] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff23c7127e __exceptionPreprocess + 350
    1   libobjc.A.dylib                     0x00007fff513fbb20 objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff23d03ab1 _CFThrowFormattedException + 194
    3   CoreFoundation                      0x00007fff23d0e4c6 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:].cold.4 + 38
    4   CoreFoundation                      0x00007fff23cced97 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 247
    5   CoreFoundation                      0x00007fff23c6d12b +[NSDictionary dictionaryWithObjects:forKeys:count:] + 59
    6   CapacitorCodepush                   0x000000010e56ea27 -[CodePushPlugin getPublicKey:] + 167
    7   Capacitor                           0x000000010e4381b6 $s9Capacitor0A6BridgeC12handleJSCall4callyAA0D0V_tFyycfU_ + 1318
    8   Capacitor                           0x000000010e42be8d $sIeg_IeyB_TR + 45
    9   libdispatch.dylib                   0x000000010edf4dd4 _dispatch_call_block_and_release + 12
    10  libdispatch.dylib                   0x000000010edf5d48 _dispatch_client_callout + 8
    11  libdispatch.dylib                   0x000000010edfc5ef _dispatch_lane_serial_drain + 788
    12  libdispatch.dylib                   0x000000010edfd17f _dispatch_lane_invoke + 422
    13  libdispatch.dylib                   0x000000010ee08a4e _dispatch_workloop_worker_thread + 719
    14  libsystem_pthread.dylib             0x00007fff5245f611 _pthread_wqthread + 421
    15  libsystem_pthread.dylib             0x00007fff5245f3fd start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

Additional Information

"@capacitor-community/http": "^1.0.0-alpha.2", "@capacitor/cli": "^3.0.0-rc.0", "@capacitor/core": "^3.0.0-rc.0", "@capacitor/device": "^0.5.6", "@capacitor/dialog": "^0.4.6", "@capacitor/filesystem": "^0.5.2", "@capacitor/ios": "^3.0.0-rc.0", "@capacitor/splash-screen": "^0.3.6", "capacitor-codepush": "github:mapiacompany/capacitor-codepush"

Repository Info

https://github.com/UserSG/CodePushWithCapacitor.git

alexcroox commented 3 years ago

I have the exact same debug output. The errors look scary but I think they are just debug callbacks as the plugin works out what directories need to be created on the first run to download and extract updates. As you can see the mkdir calls running after them along with a final "Package download success".

However my app crashes in the same place as yours, just after "Applying full update" with the same error:

⚡️  [log] - [CodePush] Applying full update
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', 
reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]'

@UserSG Did you find a resolution? @leo6104 is this something you've come across in iOS testing?

o-alexandrov commented 3 years ago

Could you please let us know, if we could help in any way? Are you guys making progress here?

priyanga-ganapathi-zoomrx commented 3 years ago

@alexcroox Unfortunately, no I couldn't able to fix it and the issue still exists in both iOS and Android. @o-alexandrov No progress was made.

lincolnthree commented 3 years ago

We have been seeing some issues where newly deployed source files cannot be loaded by the WebView after updating after a resume from suspend event. Not sure what's going on here but could be related.

lincolnthree commented 3 years ago
[CodePush] Update is installed and will be run after the app has been in the background for at least 300 seconds.
App Paused
App Resumed
[CodePush] Checking for update.
[CodePush] App is up to date.
ERROR during Navigation: 
    Errored URL - /decks 
    Previous URL - / 
     ChunkLoadError: Loading chunk 90 failed.
(error: ionic://localhost/90-es2015.76ac050118f8a1dbf311.js)

It's possible that the app restart is not occurring after the update, which would be necessary to restart the WebView, but... I'm not sure.

nonsenseless commented 3 years ago

@lincolnthree @UserSG @o-alexandrov @alexcroox

I got the same same set of messages--both couldn't find package.json and alexcroox's cannot insert nil. I ran it in Xcode and traced it up to where the plugin is trying to read the public key. If you're used to an older version of AppCenter--like I am--you might not be expecting to have to provide a private key.

This article walks you through it if you're new to doing it: https://docs.microsoft.com/en-us/appcenter/distribution/codepush/cli

Note that when you put the values into package.json, you'll have to join all the lines together using \n since json doesn't allow multiline strings.

You'll need to give the cli a path to the private key a la: appcenter codepush release -a owner/app -c www -t 1.0 --deployment-name dev -k appcenter/private.pem

Clovel commented 3 years ago
jmschlmrs commented 2 years ago

Running into a similar issue causing an iOS crash with error libc++abi: terminating with uncaught exception of type NSException *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Attempt to insert non-property list object { appVersion = "2.1.0"; deploymentKey = "redacted"; lastVersionDeploymentKey = "<null>"; lastVersionLabelOrAppVersion = "<null>"; status = 0; } for key CODE_PUSH_FAILED_STATUS_REPORT_KEY'

lastVersionDeploymentKey and lastVersionLabelOrAppVersion are of type NSNull, which is not a valid for NSUserDefaults.

The crash is avoided if strings are passed for lastVersionDeploymentKey and lastVersionLabelOrAppVersion.

Exception occurs here: https://github.com/mapiacompany/capacitor-codepush/blob/main/ios/Plugin/CodePushReportingManager.m#L88 and is triggered on the JS side here: https://github.com/mapiacompany/capacitor-codepush/blob/main/src/codePush.ts#L150

Only occurs on first/fresh installs lastVersionDeploymentKey and lastVersionLabelOrAppVersion are null. You can see that they are optional values https://github.com/mapiacompany/capacitor-codepush/blob/main/src/codePush.ts#L120.