cli icon indicating copy to clipboard operation
cli copied to clipboard

Issue with Reloading React Native Application after Disconnecting from Metro

Open vishaldybot opened this issue 1 year ago • 3 comments

Environment:

  • React Native Version
  • Operating System
  • Device Used for Testing

Description: I am encountering an issue with my React Native project during the development process. After successfully building the application using npx react-native run-android and starting the Metro bundler with npx react-native start, the application runs as expected. However, the problem arises when I disconnect the application from the Metro bundler and attempt to reload it.

Steps to Reproduce:

npx react-native run-android
npx react-native start

Disconnect the application from the Metro bundler. Attempt to reload the application by removing it from recent apps and reopening it.

Expected Result: The application should reload and function normally after being disconnected from the Metro bundler.

Actual Result: Upon trying to reload the application, I receive the following error message:

"Unable to load script. Make sure you're either running Metro (run npx react-native start) or that your bundle index.android.bundle is packaged correctly for release."

This error prevents the application from reloading properly.

Additional Information:

No significant changes were made to the project configuration that might lead to this issue. The issue persists even after attempting standard troubleshooting steps such as cleaning the build and restarting the bundler.

Impact:

This issue significantly hampers the development workflow, as it requires a complete rebuild of the application for every change when disconnected from the Metro bundler.

vishaldybot avatar Jan 13 '24 07:01 vishaldybot

Hm, @vishaldybot can you record a demo of this behaviour?

szymonrybczak avatar Jan 15 '24 14:01 szymonrybczak

Facing same issue.

umer-nazir02 avatar Apr 09 '24 05:04 umer-nazir02

@umer-nazir02 Is the issue resolved??

vishaldybot avatar May 08 '24 15:05 vishaldybot

To fix this problem we need a demo or a reproducible demo of this behavior.

szymonrybczak avatar Jun 24 '24 19:06 szymonrybczak

@szymonrybczak

Okay I will share

but as of now I have resolved the issue by using this command but not a permanent solution I would say

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/

vishaldybot avatar Jun 26 '24 09:06 vishaldybot

@vishaldybot nope. Every time this happen, I rebuild the app and then metro automatically connects.

@szymonrybczak I face this when I run the app on physical device and then disconnect the cable and reattach it. running yarn start --reset-cache do not connect with app and I need to rebuild the app every single time if cable disconnects or I restart emulator or I restart my device.

umer-nazir02 avatar Jul 11 '24 07:07 umer-nazir02

This is still alive and well. Metro disconnects ALL the time. Reconnect doesn't work, the device is not being disconnected at all. Was fine for over a year. Maybe a code related bug?

vitalNohj avatar Feb 07 '25 10:02 vitalNohj