Skip to content

Commit 2d61060

Browse files
motiz88facebook-github-bot
authored andcommitted
Default to ignoring cached Metro bundle when offline (#38076)
Summary: Pull Request resolved: #38076 Changelog: [Android][Breaking] Default to ignoring cached Metro bundle when offline Currently, on Android, if we can't find a Metro server at startup, we try to run the last cached Metro bundle instead of the prebuilt bundle asset in the APK. This is inconsistent with the iOS behaviour, and breaks bundle features that rely on a runtime Metro connection to work correctly - such as HTTP asset loading and lazy bundling (which is the default as of D43600054). Here we change the default for `ReactInstanceManager`'s `useFallbackBundle` property to `true`, which has the effect of ignoring the cached Metro bundle. This is a **breaking change** because some developers' workflows might depend on performing a build while connected to a Metro instance, then using the app standalone without access to Metro. This may be exacerbated by the fact that the RN Gradle plugin [skips including a prebuilt bundle in debug builds](https://github.com/facebook/react-native/blob/eaafc260c14674bfbf7ce3a647404c70d546854f/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt#L54). This means that, out of the box, debug builds of Android RN apps will only start if connected to Metro. (Contrast with iOS where a "fallback" bundle *is* included out of the box.) We recommend that developers always connect to a Metro server in development, and perform a release build for standalone use. Alternatively, developers can use `ReactInstanceManager.setUseFallbackBundle(false)` to restore the old behaviour. Reviewed By: javache, luluwu2032 Differential Revision: D47021957 fbshipit-source-id: 43ce8078ec95f5d65790b56f4d3dfa4f6a4e9023
1 parent 71f715a commit 2d61060

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public interface ReactInstanceEventListener
185185
private final @Nullable JSIModulePackage mJSIModulePackage;
186186
private final @Nullable ReactPackageTurboModuleManagerDelegate.Builder mTMMDelegateBuilder;
187187
private List<ViewManager> mViewManagers;
188-
private boolean mUseFallbackBundle = false;
188+
private boolean mUseFallbackBundle = true;
189189

190190
private class ReactContextInitParams {
191191
private final JavaScriptExecutorFactory mJsExecutorFactory;

0 commit comments

Comments
 (0)