[expo][expo-dev-launcher] improve error messaging in development clients #18064
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why
resolves ENG-5315
Adds some messaging to Expo Go to direct developers to custom development builds (dev clients) if they try to access a native module that doesn't exist.
This PR essentially ports our existing implementation from expo-dev-launcher into the expo package, for use in Expo Go. This does not catch all cases where a missing native module is accessed, but is a fairly straightforward change that will catch at least some cases (most specifically, those modules that try to create a
NativeEventEmitter
on iOS) while we work on a broader solution.How
If in Expo Go, replace the global JS error handler with one that does the following:
Native module cannot be null
message and its newer counterpart with a more helpful message directing users to dev clientsCodedError
s with the codeERR_UNAVAILABLE
(errors stemming from missing expo modules)Application "main" has not been registered
error, if another error was logged beforehand.Additionally, I updated the dev-launcher's implementation to look for the new counterpart of the
Native module cannot be null
message, which was changed in RN 0.65.Test Plan
I am not sure which external modules can be used to test this -- I tried
react-native-ble-manager
, but it does not use aNativeEventEmitter
, and so it doesn't trigger our code. However, I triggered it manually by callingnew NativeEventEmitter(null)
to ensure the error is intercepted correctly:Checklist
expo build
(eg: updated@expo/xdl
).expo prebuild
& EAS Build (eg: updated a module plugin).