Skip to content

Improve Android packager reconnect messaging#57101

Open
ya-nsh wants to merge 2 commits into
react:mainfrom
ya-nsh:ys/android-devtools-reconnect-ux
Open

Improve Android packager reconnect messaging#57101
ya-nsh wants to merge 2 commits into
react:mainfrom
ya-nsh:ys/android-devtools-reconnect-ux

Conversation

@ya-nsh

@ya-nsh ya-nsh commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Avoid repeated packager disconnect callbacks while the Android WebSocket is already in retry mode.
  • Add a small devsupport notifier that shows a retrying message after a previously connected Metro connection is lost.
  • Show a short reconnected message when Metro comes back after that loss.
  • Avoid showing lost-connection messaging for intentional packager shutdowns.

Changelog:

[ANDROID] [FIXED] - Improve Android Metro reconnect recovery messaging

Motivation

Android can close debugger/packager WebSockets when the app is backgrounded. This does not try to keep background sockets alive; it keeps the existing reconnect behavior and makes the recovery state clearer to developers when the app foregrounds and reconnects.

Test plan

  • PATH="/tmp/rn-yarn-bin:$HOME/.nvm/versions/node/v22.20.0/bin:$PATH" ANDROID_HOME="$HOME/Library/Android/sdk" ANDROID_SDK_ROOT="$HOME/Library/Android/sdk" ./gradlew -Preact.internal.useHermesStable=true :packages:react-native:ReactAndroid:testDebugUnitTest --tests com.facebook.react.packagerconnection.ReconnectingWebSocketTest --tests com.facebook.react.devsupport.PackagerConnectionStatusNotifierTest --tests com.facebook.react.packagerconnection.JSPackagerClientTest
  • PATH="/tmp/rn-yarn-bin:$HOME/.nvm/versions/node/v22.20.0/bin:$PATH" ANDROID_HOME="$HOME/Library/Android/sdk" ANDROID_SDK_ROOT="$HOME/Library/Android/sdk" ./gradlew -Preact.internal.useHermesStable=true :packages:react-native:ReactAndroid:ktfmtCheck

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 7, 2026
@ya-nsh ya-nsh marked this pull request as ready for review June 7, 2026 20:44
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Jun 7, 2026

@cipolleschi cipolleschi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution

@meta-codesync

meta-codesync Bot commented Jun 8, 2026

Copy link
Copy Markdown

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this in D107895817.

cipolleschi pushed a commit to cipolleschi/react-native that referenced this pull request Jun 9, 2026
Summary:
Pull Request resolved: react#57131

- Avoid repeated packager disconnect callbacks while the Android WebSocket is already in retry mode.
- Add a small devsupport notifier that shows a retrying message after a previously connected Metro connection is lost.
- Show a short reconnected message when Metro comes back after that loss.
- Avoid showing lost-connection messaging for intentional packager shutdowns.

Changelog:
[ANDROID][FIXED] - Improve Android Metro reconnect recovery messaging

## Motivation

Android can close debugger/packager WebSockets when the app is backgrounded. This does not try to keep background sockets alive; it keeps the existing reconnect behavior and makes the recovery state clearer to developers when the app foregrounds and reconnects.

Pull Request resolved: react#57101

Test Plan:
- `PATH="/tmp/rn-yarn-bin:$HOME/.nvm/versions/node/v22.20.0/bin:$PATH" ANDROID_HOME="$HOME/Library/Android/sdk" ANDROID_SDK_ROOT="$HOME/Library/Android/sdk" ./gradlew -Preact.internal.useHermesStable=true :packages:react-native:ReactAndroid:testDebugUnitTest --tests com.facebook.react.packagerconnection.ReconnectingWebSocketTest --tests com.facebook.react.devsupport.PackagerConnectionStatusNotifierTest --tests com.facebook.react.packagerconnection.JSPackagerClientTest`
- `PATH="/tmp/rn-yarn-bin:$HOME/.nvm/versions/node/v22.20.0/bin:$PATH" ANDROID_HOME="$HOME/Library/Android/sdk" ANDROID_SDK_ROOT="$HOME/Library/Android/sdk" ./gradlew -Preact.internal.useHermesStable=true :packages:react-native:ReactAndroid:ktfmtCheck`

Reviewed By: javache

Differential Revision: D107895817

Pulled By: cipolleschi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants