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 VPN toggle failures #858

Merged
merged 1 commit into from
Jun 21, 2024
Merged

Conversation

diegoreymendez
Copy link
Contributor

@diegoreymendez diegoreymendez commented Jun 21, 2024

Task/Issue URL: https://app.asana.com/0/1207603085593419/1207629954356116/f

iOS PR: duckduckgo/iOS#2979
macOS PR: duckduckgo/macos-browser#2892

What kind of version bump will this require?: Patch

Description

The VPN toggle is sometimes failing silently, apparently due to a race condition created by calls to sendProviderMessage while the VPN is starting up.

This PR changes our logic to limit when those calls are made, since none of them make sense to call when the VPN is connecting.

Testing

See platform-specific PRs for instructions.


Internal references:

Software Engineering Expectations
Technical Design Template

@diegoreymendez diegoreymendez self-assigned this Jun 21, 2024
@diegoreymendez diegoreymendez marked this pull request as ready for review June 21, 2024 10:07
@diegoreymendez diegoreymendez changed the base branch from main to release/156.0.0-2 June 21, 2024 10:09
@@ -88,7 +88,9 @@ public class ConnectionErrorObserverThroughSession: ConnectionErrorObserver {

private func handleStatusChangeNotification(_ notification: Notification) {
do {
guard let session = ConnectionSessionUtilities.session(from: notification) else {
guard let session = ConnectionSessionUtilities.session(from: notification),
session.status == .disconnected else {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't need error information if the VPN is connected.

@@ -98,6 +98,10 @@ public class ConnectionServerInfoObserverThroughSession: ConnectionServerInfoObs
// MARK: - Obtaining the NetP VPN status

private func updateServerInfo(session: NETunnelProviderSession) async {
guard session.status == .connected else {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We only need server info if the VPN is connected.

@@ -99,7 +99,9 @@ public class DataVolumeObserverThroughSession: DataVolumeObserver {

private func updateDataVolume() {
Task {
guard let session = await tunnelSessionProvider.activeSession() else {
guard let session = await tunnelSessionProvider.activeSession(),
session.status == .connected else {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We only need data volume if the VPN is connected.

Copy link
Contributor

@aataraxiaa aataraxiaa left a comment

Choose a reason for hiding this comment

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

LGTM. Will validate changes in client PRs.

@diegoreymendez diegoreymendez merged commit 2806adf into release/156.0.0-2 Jun 21, 2024
14 checks passed
@diegoreymendez diegoreymendez deleted the diego/fix-vpn-toggle branch June 21, 2024 12:11
diegoreymendez added a commit to duckduckgo/macos-browser that referenced this pull request Jun 21, 2024
Task/Issue URL:
https://app.asana.com/0/1207603085593419/1207629954356116/f

iOS PR: duckduckgo/iOS#2979
BSK PR: duckduckgo/BrowserServicesKit#858

## Description

The VPN toggle is sometimes failing silently, apparently due to a race
condition created by calls to `sendProviderMessage` while the VPN is
starting up.

This PR changes our logic to limit when those calls are made, since none
of them make sense to call when the VPN is connecting.
diegoreymendez added a commit to duckduckgo/iOS that referenced this pull request Jun 21, 2024
Task/Issue URL: https://app.asana.com/0/1207603085593419/1207629954356116/f

macOS PR: duckduckgo/macos-browser#2892
BSK PR: duckduckgo/BrowserServicesKit#858

## Description

The VPN toggle is sometimes failing silently, apparently due to a race condition created by calls to `sendProviderMessage` while the VPN is starting up.

This PR changes our logic to limit when those calls are made, since none of them make sense to call when the VPN is connecting.
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