bugsnag / bugsnag-expo

MIT License
10 stars 5 forks source link

TypeError: Cannot read property 'developer' of null #144

Closed Meilo closed 11 months ago

Meilo commented 11 months ago

Describe the bug

After upgrade @bugsnag/expo to 49.0.0 this error manifest on a standalone app.

I saw in the code base on the lib, and i think that the problem is here

Capture d’écran 2023-08-02 à 09 40 39

developer is not a key of Constants.expoConfig object.

Steps to reproduce

  1. Upgrade @bugsnag/expo to 49.0.0
  2. Run standalone app
  3. See error

Environment

Error messages: ``` TypeError: Cannot read property 'developer' of null ```
giaset commented 11 months ago

Just lost a day to this... Basically it works when you run code from the embedded JS bundle, but the second you publish an update (we use EAS Update), one of expoConfig or expoGoConfig is null

This causes the updated bundle to crash on launch, and expo-updates to rollback to the embedded bundle

I've temporarily patched the config.js file using patch-package as follows:

diff --git a/node_modules/@bugsnag/expo/src/config.js b/node_modules/@bugsnag/expo/src/config.js
index 7100273..c61dbec 100644
--- a/node_modules/@bugsnag/expo/src/config.js
+++ b/node_modules/@bugsnag/expo/src/config.js
@@ -7,7 +7,7 @@ const stringWithLength = require('@bugsnag/core/lib/validators/string-with-lengt
 // If the developer property is not present it means the app is
 // not connected to a development tool and is either a published app running in
 // the Expo client, or a standalone app
-const IS_PRODUCTION = !Constants.expoConfig.developer && !Constants.expoGoConfig.developer
+const IS_PRODUCTION = !Constants.expoConfig?.developer && !Constants.expoGoConfig?.developer

 // The app can still run in production "mode" in development environments, in which
 // cases the global boolean __DEV__ will be set to true
yousif-bugsnag commented 11 months ago

Hi @giaset thanks for the report. We've now released a fix for this in v49.0.1