fix(switch): stop offline sends raising the system connection dialog - #2833
Open
bitsandfoxes wants to merge 6 commits into
Open
fix(switch): stop offline sends raising the system connection dialog#2833bitsandfoxes wants to merge 6 commits into
bitsandfoxes wants to merge 6 commits into
Conversation
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
bitsandfoxes
force-pushed
the
fix/switch-offline-sends
branch
from
September 4, 2026 11:56
b86e1c9 to
5b414f8
Compare
This was referenced Sep 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
A Switch game that is offline showed the system "connect to the internet" dialog every couple of seconds, indefinitely.
UnityWebRequestTransportopens 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 returnednull, which also skipped the rate-limit handling inHttpTransportBase. 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.NetworkErrorso client reports still account for them instead of them vanishing. Reachability moves behindIApplicationso 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.internetReachabilityreports a Switch console as reachable while it is offline. From the device:sentry-switchnow exposessentry_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.SentryNativeSwitchsupplies it asNetworkAvailabilityProbeand 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:
No
Failed to send request, no backoff, no dialogs — noUnityWebRequestis ever constructed, so nothing can raise one.