Running into a weird error when deploying to Heroku, but works just fine in Expo app when developing

Please provide the following:

  1. SDK Version: 34
  2. Platforms(Android/iOS/web/all): Android (all, but tested on Android)

Hello,

Ok, so the weirdest thing is happening. I have no idea where to go from here, help please.

Ok so anyway, everything works fine when I’m developing within the Expo app. But when the following line is hit on my prod/Heroku environment, my app just dies

      const tokenInLocalStorage =
        (await SecureStore.getItemAsync("jwt")) ?? null;

And, given that this error isn’t thrown in my dev environment, I went through a lot of trouble actually catching this error (ie, I wrapped the whole method in a try..catch, deployed my backend with a custom route, and caught the error at that route from the client try..catch when sending the error in the post body).

Anyway. What the heck is going on? Here is the error:

{ 
   "framesToPop":1,
   "nativeStackAndroid":[ 
      { 
         "methodName":"engineDoFinal",
         "lineNumber":517,
         "file":"AndroidKeyStoreCipherSpiBase.java"
      },
      { 
         "methodName":"doFinal",
         "lineNumber":2055,
         "file":"Cipher.java"
      },
      { 
         "methodName":"decryptItem",
         "lineNumber":433,
         "file":"SecureStoreModule.java"
      },
      { 
         "methodName":"readJSONEncodedItem",
         "lineNumber":188,
         "file":"SecureStoreModule.java"
      },
      { 
         "methodName":"getItemImpl",
         "lineNumber":159,
         "file":"SecureStoreModule.java"
      },
      { 
         "methodName":"getValueWithKeyAsync",
         "lineNumber":147,
         "file":"SecureStoreModule.java"
      },
      { 
         "methodName":"invoke",
         "lineNumber":-2,
         "file":"Method.java"
      },
      { 
         "methodName":"invokeExportedMethod",
         "lineNumber":97,
         "file":"ExportedModule.java"
      },
      { 
         "methodName":"callMethod",
         "lineNumber":117,
         "file":"NativeModulesProxy.java"
      },
      { 
         "methodName":"invoke",
         "lineNumber":-2,
         "file":"Method.java"
      }
   ],
   "userInfo":null,
   "code":"E_SECURESTORE_DECRYPT_ERROR",
   "line":22,
   "column":1799,
   "sourceURL":"/data/user/0/com.myapp.app/files/35.0.0/cached-bundle-experience-%40myname%2Fchattenger496511176-35.0.0"
}

Here is a similar error buuut, I can’t see a reply to the OP. No idea how to resolve this.

I’m not sure what you mean by your “Heroku environment” - this is code running on an Android phone, right? How is Heroku involved?

A few ideas:

  • SecureStore doesn’t work on Android 5.x
  • Very occasionally, something breaks in prod JS that doesn’t in development due to the differences when transpiling . Use the “production mode” flag on the Expo web console that appears after running expo --start to simulate production javascript.
  • Along the same idea as the last troubleshooting step, very occasionally you’ll get different results when you’re debugging in Chrome vs just running the app in dev/ prod, because when debugging, the code is using Chrome’s JavaScript engine instead of JavaScript Core or whatever.

Took a while to find this, but this cleared the issue for me:

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.