Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(web, isConnected): Return actual connection state even if network type is 'unknown' #544

Merged
merged 3 commits into from Nov 29, 2021

Conversation

eVoloshchak
Copy link
Contributor

@eVoloshchak eVoloshchak commented Nov 28, 2021

Overview

Whenever connection type is 'unknown', library returns isConnected=false instead of actual connection state. Unknown network type does not necessarily mean that we have no internet connection. For instance, Electron apps and apps running on chromebooks with instant tethering enabled return 'unknown' network type even when connected to the internet.

Reasoning

We should return the correct connection state even for 'unknown' connection type

Test Plan

  1. Launch app on chromebook with instant tethering enabled
  2. Bind change event listeners to the NetworkInformation
  3. Verify that isConnected property is present in state returned from the listener and that it indicates actual network state

Fixes #450

Copy link
Contributor

@mikehardy mikehardy left a comment

Choose a reason for hiding this comment

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

I worry about altering the isConnected type, as mentioned in the comment tagged on that line, this would be breaking and reverse an intentional change made earlier this year

src/internal/nativeModule.web.ts Show resolved Hide resolved
src/internal/types.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@mikehardy mikehardy left a comment

Choose a reason for hiding this comment

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

just docs now as commented with specifics, then good to go

Copy link
Contributor

@mikehardy mikehardy left a comment

Choose a reason for hiding this comment

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

Looks excellent, CI checks then 🚀

@mikehardy mikehardy added the pending merge A PR that will be merged shortly, waiting for CI or final comment label Nov 29, 2021
@mikehardy mikehardy changed the title fix: Return actual connection state when network type is 'unknown' fix(web, isConnected): Return actual connection state even if network type is 'unknown' Nov 29, 2021
@mikehardy mikehardy merged commit 36d6dc9 into react-native-netinfo:master Nov 29, 2021
@mikehardy mikehardy removed the pending merge A PR that will be merged shortly, waiting for CI or final comment label Nov 29, 2021
github-actions bot pushed a commit that referenced this pull request Nov 29, 2021
## [7.1.3](v7.1.2...v7.1.3) (2021-11-29)

### Bug Fixes

* **web, isConnected:** Return actual connection state even if network type is 'unknown' ([#544](#544)) ([36d6dc9](36d6dc9))
@matt-oakes
Copy link
Collaborator

🎉 This PR is included in version 7.1.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Web - Why do "unknown" connection types return isConnected: null ?
3 participants