Skip to content

NetInfo.refresh() Temporarily Reports isInternetReachable as true When Offline #745

@yahya-evoly

Description

@yahya-evoly

Environment

System:
  OS: macOS 15.1
  CPU: (12) arm64 Apple M2 Pro
  Memory: 94.47 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.10.0
    path: /var/folders/rp/z45z790578j3dz2yyzcgk8sr0000gn/T/yarn--1730972878942-0.26554930597658855/node
  Yarn:
    version: 1.22.19
    path: /var/folders/rp/z45z790578j3dz2yyzcgk8sr0000gn/T/yarn--1730972878942-0.26554930597658855/yarn
  npm:
    version: 10.2.3
    path: /usr/local/bin/npm
  Watchman:
    version: 2024.09.09.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.1
      - iOS 18.1
      - macOS 15.1
      - tvOS 18.1
      - visionOS 2.1
      - watchOS 11.1
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.1 AI-241.18034.62.2412.12266719
  Xcode:
    version: 16.1/16B40
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.12
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.74.5
    wanted: 0.74.5
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Platforms

both Android and iOS

Versions

  • expo: ~51.0.28
  • react-native-netinfo: 11.3.1
  • react-native: 0.74.5
  • react: 18.2.0

Description

I’m experiencing an issue where, with a custom reachability URL configuration, calling NetInfo.refresh() causes isInternetReachable to temporarily report true even though the device is offline. This brief incorrect online status can lead to unintended side effects in applications that rely on accurate network status, such as triggering paused mutations or other network-dependent operations.

Reproducible Demo

I’ve created a minimal reproducible example demonstrating the issue, which is available at my GitHub repository:
https://github.com/yahya-evoly/NetInfoRefreshBugDemo

Details:

  • With the reachability URL set to fail, isInternetReachable correctly reports false.
  • Upon calling the “NetInfo.refresh()”method, isInternetReachable changes to true momentarily before reverting to false.

Request

Could you please investigate this behavior? Is this a known issue or a bug that can be addressed? Ideally, isInternetReachable would consistently report false when the reachability URL is set to fail, regardless of NetInfo.refresh() calls.

Any guidance or workaround would be greatly appreciated!
Thank you for your time and assistance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions