Skip to content

fix(switch): stop offline sends raising the system connection dialog - #2833

Open
bitsandfoxes wants to merge 6 commits into
mainfrom
fix/switch-offline-sends
Open

fix(switch): stop offline sends raising the system connection dialog#2833
bitsandfoxes wants to merge 6 commits into
mainfrom
fix/switch-offline-sends

Conversation

@bitsandfoxes

@bitsandfoxes bitsandfoxes commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

The bug

A Switch game that is offline showed the system "connect to the internet" dialog every couple of seconds, indefinitely.

UnityWebRequestTransport opens a connection per envelope, and on Switch the attempt itself is what raises the dialog. With logs and metrics both flushing on a 5s timer, that is a constant stream of popups. A connection error only logged a warning and returned null, which also skipped the rate-limit handling in HttpTransportBase. Nothing anywhere recorded that the network was down, and the next envelope tried again immediately.

The what

Back off after a connection error — exponentially, 1s up to 300s, resetting on the first success. Envelopes turned away are recorded as DiscardReason.NetworkError so client reports still account for them instead of them vanishing. Reachability moves behind IApplication so the behaviour is testable.

Ask sentry-switch whether the network is usable. This is the part that actually removes the dialogs with the native support enabled. Asking Unity turned out to be untrustworthy here because Application.internetReachability reports a Switch console as reachable while it is offline. From the device:

Failed to send request: No Internet Connection.
Reachability reported as ReachableViaLocalAreaNetwork.

sentry-switch now exposes sentry_switch_utils_is_network_available(), see https://github.com/getsentry/sentry-switch/pull/188, which utilizes the console's network interface manager without submitting a network request. No request, not dialog. SentryNativeSwitch supplies it as NetworkAvailabilityProbe and the transport prefers it, falling back to reachability when no probe is set, which leaves WebGL and the unknown-platform path unchanged.

Verified on a Switch 2 devkit

Offline, with the probe in place:

Sentry: (Debug) Using the native SDK to determine network availability.
Sentry: (Debug) No network available. Dropping envelope instead of attempting to send.

No Failed to send request, no backoff, no dialogs — no UnityWebRequest is ever constructed, so nothing can raise one.

bitsandfoxes and others added 2 commits September 4, 2026 13:54
UnityWebRequestTransport opens a connection per envelope. On Nintendo Switch
every attempt made while the console is offline raises the system "connect to the
internet" dialog, and because logs and metrics each flush on a 5s timer that
turned into a prompt every couple of seconds. A connection error previously only
logged a warning and returned null, which also skipped the rate-limit handling in
HttpTransportBase, so nothing anywhere recorded that the network was down.

Add two guards to SendEnvelopeAsync: skip sending entirely while the platform
reports NotReachable, and back off exponentially (1s up to 60s) after a
connection error, resetting on the first success. The backoff is what covers
platforms whose reachability cannot be trusted, and the case where the network
drops after startup. Both paths record DiscardReason.NetworkError so client
reports still account for the drops.

Reachability goes through IApplication rather than UnityEngine.Application so the
behaviour is testable.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ABHTqM37qGAc9iQZcdbdY8
…chability

Application.internetReachability reports a Switch console as reachable while it
is offline - the device logs show "Reachability reported as
ReachableViaLocalAreaNetwork" next to every failed send. The reachability gate in
the transport was therefore inert on the one platform it was meant to protect,
leaving the connection-error backoff to absorb everything. Since attempting the
connection is itself what raises the system "connect to the internet" dialog,
that still meant a dialog per attempt, just at the backoff's cadence.

Let the platform answer instead. sentry-switch now exposes
sentry_switch_utils_is_network_available(), which asks the console's network
interface manager without submitting a network request, so asking costs nothing
and shows no dialog. SentryNativeSwitch hands it to the options as
NetworkAvailabilityProbe and the transport prefers it, falling back to
reachability where no probe is set - which keeps WebGL and the unknown-platform
path behaving as before.

The stub returns 1 so builds without the native library keep today's behaviour
and rely on the backoff.

Requires a sentry-switch build that exports the new function: the P/Invoke goes
through __Internal against a statically linked archive, so it resolves at link
time rather than falling back at runtime.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ABHTqM37qGAc9iQZcdbdY8
Comment thread src/Sentry.Unity/UnityWebRequestTransport.cs
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.

1 participant