Skip to content

fix: treat unknown/constrained network access as connected - #323

Merged
tanderson-ld merged 1 commit into
mainfrom
ta/SDK-2755/unknown-connectivity-optimistic
Jul 28, 2026
Merged

tanderson-ld merged 1 commit into
mainfrom
ta/SDK-2755/unknown-connectivity-optimistic

Conversation

@tanderson-ld

@tanderson-ld tanderson-ld commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Microsoft.Maui.Networking.Connectivity.Current.NetworkAccess can transiently report Unknown at process start — MAUI's platform callback (NetworkCallback on Android, NWPathMonitor on iOS/macOS, NetworkInformation on Windows) hasn't yet been given the initial availability signal by the framework. Because DefaultConnectivityStateManager.UpdateConnectedStatus previously required exactly Internet, LdClient's constructor read _networkEnabled = false, Start() took the offline fast-exit branch in ConnectionManager.OpenOrCloseConnectionIfNecessary, and Init returned "success" in ~300ms with an empty flag store. The SDK then had to wait for MAUI to fire ConnectivityChanged before it would even attempt to open a stream.

This PR updates IsConsideredConnected to treat Unknown and ConstrainedInternet as connected in addition to Internet. Local and None remain disconnected.

Scope

  • Affects all MAUI targets (Android / iOS / Mac Catalyst / Windows) because DefaultConnectivityStateManager is shared code and PlatformConnectivity.LdNetworkAccess maps directly to MAUI's cross-platform Connectivity.NetworkAccess. The Connectivity.maui.cs implementation is compiled into every MAUI target via <Compile Include="**\*.maui.cs"/> in each target's ItemGroup.
  • Not affected: netstandard consumers. Connectivity.netstandard.cs returns LdNetworkAccess.Internet unconditionally, so it never hit the buggy branch and doesn't hit the new one either.

Why not "anything but None"

ConnectionManager.SetNetworkEnabled(bool) is a no-op when the value doesn't change. If we optimistically treated Local as connected, the eventual Local -> Internet transition wouldn't trigger OpenOrCloseConnectionIfNecessary (the boolean already matches), and the SDK would rely on the EventSource's internal retry backoff — up to ~30s late reconnecting after network fully recovers. Keeping Local disconnected preserves the deterministic wake-up on that transition. ConstrainedInternet (captive portals, metered restrictions) typically resolves upward to Internet, so attempting is cheap and the same race isn't a concern in practice.

Test plan

  • dotnet test pkgs/sdk/client/test/LaunchDarkly.ClientSdk.Tests -f net8.0 — 377/377 passing, including 5 new tests in DefaultConnectivityStateManagerTest covering every LdNetworkAccess enum value.
  • Cross-target compile check under .NET 8 SDK — all six target frameworks build 0 errors: netstandard2.0, net8.0, net8.0-android, net8.0-ios, net8.0-maccatalyst, net8.0-windows. Confirmed IsConsideredConnected is present in the iOS and Mac Catalyst output DLLs.
  • Manual verification on a MAUI Android app that fresh-install cold start no longer hits the offline branch.

@tanderson-ld
tanderson-ld requested a review from a team as a code owner July 28, 2026 14:13
@tanderson-ld tanderson-ld changed the title fix: treat unknown/constrained network access as connected at MAUI cold start (SDK-2755) fix: treat unknown/constrained network access as connected Jul 28, 2026
@tanderson-ld
tanderson-ld merged commit a633c9a into main Jul 28, 2026
21 checks passed
@tanderson-ld
tanderson-ld deleted the ta/SDK-2755/unknown-connectivity-optimistic branch July 28, 2026 14:31
tanderson-ld pushed a commit that referenced this pull request Jul 28, 2026
🤖 I have created a release *beep* *boop*
---


##
[5.9.3](LaunchDarkly.ClientSdk-v5.9.2...LaunchDarkly.ClientSdk-v5.9.3)
(2026-07-28)


### Bug Fixes

* treat unknown/constrained network access as connected
([#323](#323))
([a633c9a](a633c9a))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Mechanical release/version metadata only in this PR; the behavioral
fix ships in the tagged release, not as new logic in the diff.
> 
> **Overview**
> Release Please bumps **LaunchDarkly.ClientSdk** from **5.9.2** to
**5.9.3** across the manifest, `LaunchDarkly.ClientSdk.csproj`,
`CHANGELOG.md`, and `PROVENANCE.md`.
> 
> The **5.9.3** patch documents bug fix
[#323](#323):
connectivity handling now treats **unknown** and **constrained** network
access (e.g. MAUI cold-start `Unknown`, metered **ConstrainedInternet**)
as **connected**, so the client is less likely to stay offline or skip
reconnecting when the OS has not yet reported full internet access.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
5fb1731. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
evgenygunko pushed a commit to evgenygunko/CopyWordsDA that referenced this pull request Jul 29, 2026
This PR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [LaunchDarkly.ClientSdk](https://github.com/launchdarkly/dotnet-core) | `5.9.1` → `5.9.3` | ![age](https://developer.mend.io/api/mc/badges/age/nuget/LaunchDarkly.ClientSdk/5.9.3?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/nuget/LaunchDarkly.ClientSdk/5.9.1/5.9.3?slim=true) |

---

### Release Notes

<details>
<summary>launchdarkly/dotnet-core (LaunchDarkly.ClientSdk)</summary>

### [`v5.9.3`](https://github.com/launchdarkly/dotnet-core/releases/tag/LaunchDarkly.ClientSdk-v5.9.3): LaunchDarkly.ClientSdk: v5.9.3

[Compare Source](launchdarkly/dotnet-core@LaunchDarkly.ClientSdk-v5.9.2...LaunchDarkly.ClientSdk-v5.9.3)

##### Bug Fixes

- treat unknown/constrained network access as connected ([#&#8203;323](launchdarkly/dotnet-core#323)) ([a633c9a](launchdarkly/dotnet-core@a633c9a))

***

This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).

<!-- CURSOR_SUMMARY -->

### [`v5.9.2`](https://github.com/launchdarkly/dotnet-core/releases/tag/LaunchDarkly.ClientSdk-v5.9.2): LaunchDarkly.ClientSdk: v5.9.2

[Compare Source](launchdarkly/dotnet-core@LaunchDarkly.ClientSdk-v5.9.1...LaunchDarkly.ClientSdk-v5.9.2)

##### Bug Fixes

- add defensive cycle guard to prerequisite evaluation ([#&#8203;317](launchdarkly/dotnet-core#317)) ([babb87a](launchdarkly/dotnet-core@babb87a))

***

This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).

<!-- CURSOR_SUMMARY -->

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or PR is renamed to start with "rebase!".

👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired.

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
tanderson-ld added a commit that referenced this pull request Aug 10, 2026
…all (SDK-2755) (#328)

**Related issues**

- Fix PR in dotnet-eventsource:
launchdarkly/dotnet-eventsource#124
- 5.3.2 release notes:
https://github.com/launchdarkly/dotnet-eventsource/releases/tag/5.3.2

**Describe the solution you've provided**

Bumps `LaunchDarkly.EventSource` from 5.3.1 to 5.3.2 in
`LaunchDarkly.ClientSdk`. The 5.3.2 release increases the SSE read
buffer from 1024 to 8192 bytes to bypass a stall in
`Xamarin.Android.Net.AndroidMessageHandler`'s BufferedStream small-count
code path, which caused MAUI Android consumers' SSE reads to block for
~60 s waiting for the next server keepalive.

The fix was validated end-to-end with a new sse-contract-tests
payload-size sweep run against a .NET-for-Android build of the SSE test
service in an Android emulator; the sweep flags every regression to a
sub-4096-byte buffer.

**Describe alternatives you've considered**

- Working around the stall in-repo (e.g., swapping out
`AndroidMessageHandler` for a different HTTP handler) was rejected as
riskier than adjusting the buffer size at the SSE layer.
- The `ServerSdk` consumer of `LaunchDarkly.EventSource` is out of scope
for this PR: the stall is Android-only, so bumping `ServerSdk` would be
pure hygiene rather than a fix.

**Additional context**

- No API changes; single-line `PackageReference` version bump.
- Companion to previously merged #323, which addressed the
network-connectivity side of the same customer-reported symptom.
- Verified locally that `LaunchDarkly.ClientSdk` builds cleanly against
5.3.2 for both `netstandard2.0` and `net8.0-android`.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Overview**
> **Bumps** `LaunchDarkly.EventSource` from **5.3.1** to **5.3.2** in
`LaunchDarkly.ClientSdk` only (no API or source changes).
> 
> The newer EventSource release increases the SSE read buffer (1024 →
8192 bytes) so MAUI Android clients avoid long (~60s) stalls when
`AndroidMessageHandler`’s buffered stream blocks on small reads until
the next keepalive. `LaunchDarkly.ServerSdk` is intentionally left on
5.3.1 because the issue is Android-specific.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
b73204d. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants