Debugger: DevTools/Metro is disconnecting from the websocket if the app is backgrounded - was: `AppState.addEventListener('change')` on Android seems to suddenly stop working
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 127k
- Forks
- 25.3k
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 4
Description
Description
AppState.addEventListener('change' on Android seems to suddenly stop working.
Steps to reproduce
https://github.com/NorseGaud/expo-testing
npx expo run:android
Once up and running, background the app by switching to something like the Contacts app. Then, open a contact, create a contact, etc, and then come back. You won't see the active log. However, if you just background the app and don't do anything significant it will show active logs switching back.
React Native Version
0.79.3
Affected Platforms
Runtime - Android
Output of npx @react-native-community/cli info
❯ npx @react-native-community/cli info
info Fetching system and libraries information...
System:
OS: macOS 15.5
CPU: (8) arm64 Apple M2
Memory: 121.03 MB / 24.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 21.7.3
path: ~/.nvm/versions/node/v21.7.3/bin/node
Yarn:
version: 1.22.21
path: /opt/homebrew/bin/yarn
npm:
version: 10.8.3
path: ~/.nvm/versions/node/v21.7.3/bin/npm
Watchman:
version: 2025.04.14.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.15.2
path: /opt/homebrew/opt/ruby/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 24.5
- iOS 18.5
- macOS 15.5
- tvOS 18.5
- visionOS 2.5
- watchOS 11.5
Android SDK:
API Levels:
- "26"
- "27"
- "28"
- "29"
- "30"
- "31"
- "32"
- "33"
- "34"
- "35"
- "36"
Build Tools:
- 26.0.3
- 30.0.3
- 33.0.1
- 34.0.0
- 35.0.0
- 36.0.0
System Images:
- android-26 | Google APIs Intel x86_64 Atom
- android-28 | Google ARM64-V8a Play ARM 64 v8a
- android-29 | Google Play ARM 64 v8a
- android-30 | Google Play ARM 64 v8a
- android-34 | Google APIs ARM 64 v8a
- android-34 | Google Play ARM 64 v8a
- android-35 | Google Play ARM 64 v8a
- android-36 | Google Play ARM 64 v8a
- android-UpsideDownCakePrivacySandbox | Google Play ARM 64 v8a
Android NDK: Not Found
IDEs:
Android Studio: 2025.1 AI-251.25410.109.2511.13665796
Xcode:
version: 16.4/16F6
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.13
path: /usr/bin/javac
Ruby:
version: 3.3.6
path: /opt/homebrew/opt/ruby/bin/ruby
npmPackages:
"@react-native-community/cli":
installed: 18.0.0
wanted: ^18.0.0
react:
installed: 19.0.0
wanted: 19.0.0
react-native:
installed: 0.79.3
wanted: 0.79.3
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: true
newArchEnabled: true
info React Native v0.80.1 is now available (your project is running on v0.79.3).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.80.1
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.79.3&to=0.80.1
info For more info, check out "https://reactnative.dev/docs/upgrading?os=macos".
Stacktrace or Logs
LOG AppState has come to the background! 0.6961324593405451
LOG AppState has come to the active! 0.6961324593405451
MANDATORY Reproducer
https://github.com/NorseGaud/expo-testing
Screenshots and Videos
https://github.com/user-attachments/assets/f9f564b7-3495-4054-953f-e843a5ae2312
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the mandatory reproducer at github.com/NorseGaud/expo-testing and run npx expo run:android. Background the app, use another app, return, and compare AppState logs with the DevTools/Metro websocket connection; done means backgrounding no longer prevents the expected active logs or disconnects the debugging connection.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, react-native
- Domain
- developer-experience, mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100