-
-
Notifications
You must be signed in to change notification settings - Fork 62
fix(switch): stop offline sends raising the system connection dialog #2833
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
Open
bitsandfoxes
wants to merge
6
commits into
main
Choose a base branch
from
fix/switch-offline-sends
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
45ea5f7
fix(switch): stop the transport from reconnecting blindly while offline
bitsandfoxes 5b414f8
fix(switch): ask the platform for network availability instead of rea…
bitsandfoxes 4ff9f05
comments
bitsandfoxes 3394626
simplified backing off mechanism
bitsandfoxes a1ac88e
updated changelog
bitsandfoxes 67d2544
restore client report
bitsandfoxes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| using NUnit.Framework; | ||
| using Sentry.Protocol.Envelopes; | ||
| using Sentry.Unity.Tests.Stubs; | ||
| using UnityEngine; | ||
|
|
||
| namespace Sentry.Unity.Tests; | ||
|
|
||
| [TestFixture] | ||
| public class UnityWebRequestTransportTests | ||
| { | ||
| private static SentryUnityOptions CreateOptions() => new() | ||
| { | ||
| Dsn = SentryTests.TestDsn | ||
| }; | ||
|
|
||
| private static Envelope CreateEnvelope() => Envelope.FromEvent(new SentryEvent()); | ||
|
|
||
| /// <summary> | ||
| /// A coroutine that yields has created a <see cref="UnityEngine.Networking.UnityWebRequest"/>, | ||
| /// which is what raises the system connection dialog on platforms like the Nintendo Switch. | ||
| /// </summary> | ||
| [Test] | ||
| public void SendEnvelopeAsync_NetworkNotReachable_DoesNotOpenAConnection() | ||
| { | ||
| var application = new TestApplication { InternetReachability = NetworkReachability.NotReachable }; | ||
| var transport = new UnityWebRequestTransport(CreateOptions(), application); | ||
|
|
||
| var enumerator = transport.SendEnvelopeAsync(CreateEnvelope()); | ||
|
|
||
| Assert.IsFalse(enumerator.MoveNext(), "The transport attempted to send while offline."); | ||
| } | ||
|
|
||
| [Test] | ||
| public void SendEnvelopeAsync_NetworkReachable_AttemptsToSend() | ||
| { | ||
| var application = new TestApplication | ||
| { | ||
| InternetReachability = NetworkReachability.ReachableViaLocalAreaNetwork | ||
| }; | ||
| var transport = new UnityWebRequestTransport(CreateOptions(), application); | ||
|
|
||
| var enumerator = transport.SendEnvelopeAsync(CreateEnvelope()); | ||
|
|
||
| Assert.IsTrue(enumerator.MoveNext(), "The transport did not attempt to send while online."); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// The probe has the final say: on Nintendo Switch reachability claims the console is reachable | ||
| /// while it is offline, which is the state the dialog gets raised in. | ||
| /// </summary> | ||
| [Test] | ||
| public void SendEnvelopeAsync_ProbeReportsNoNetwork_OverridesReachability() | ||
| { | ||
| var application = new TestApplication | ||
| { | ||
| InternetReachability = NetworkReachability.ReachableViaLocalAreaNetwork | ||
| }; | ||
| var options = CreateOptions(); | ||
| options.NetworkAvailabilityProbe = () => false; | ||
| var transport = new UnityWebRequestTransport(options, application); | ||
|
|
||
| var enumerator = transport.SendEnvelopeAsync(CreateEnvelope()); | ||
|
|
||
| Assert.IsFalse(enumerator.MoveNext(), "The transport ignored the platform's network probe."); | ||
| } | ||
|
|
||
| [Test] | ||
| public void SendEnvelopeAsync_ProbeReportsNetwork_OverridesReachability() | ||
| { | ||
| var application = new TestApplication { InternetReachability = NetworkReachability.NotReachable }; | ||
| var options = CreateOptions(); | ||
| options.NetworkAvailabilityProbe = () => true; | ||
| var transport = new UnityWebRequestTransport(options, application); | ||
|
|
||
| var enumerator = transport.SendEnvelopeAsync(CreateEnvelope()); | ||
|
|
||
| Assert.IsTrue(enumerator.MoveNext(), "The transport ignored the platform's network probe."); | ||
| } | ||
| } |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.