-
Notifications
You must be signed in to change notification settings - Fork 37
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
VPN is sometimes stopped twice #1213
Conversation
@@ -700,7 +700,6 @@ open class PacketTunnelProvider: NEPacketTunnelProvider { | |||
} | |||
|
|||
Logger.networkProtection.error("🔴 Stopping VPN due to no auth token") | |||
await cancelTunnel(with: TunnelError.startingTunnelWithoutAuthToken) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to cancel the tunnel if we're throwing an error below, which is the right way to cancel startup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, yeah good catch.
case .vpnAccessRevoked: | ||
return "VPN disconnected due to expired subscription" | ||
case .couldNotGenerateTunnelConfiguration(let internalError): | ||
return "Failed to generate a tunnel configuration: \(internalError.localizedDescription)" | ||
case .simulateTunnelFailureError: | ||
return "Simulated a tunnel error as requested" | ||
case .tokenReset: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Differentiating a specific case that was previously reported as startingTunnelWithoutAuthToken
.
} | ||
case .reset: | ||
// This case should in theory not be possible, but it's ideal to have this in place | ||
// in case an error in the controller on the client side allows it. | ||
try await tokenHandler.removeToken() | ||
throw TunnelError.startingTunnelWithoutAuthToken | ||
try? await tokenHandler.removeToken() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if this fails, this isn't the real failure reason - the real failure reason is the token is being removed which, as described above, is an abnormal scenario. The removal failing shouldn't be the error we get.
@@ -603,22 +608,22 @@ open class PacketTunnelProvider: NEPacketTunnelProvider { | |||
try await tokenHandler.refreshToken() | |||
} catch { | |||
Logger.networkProtection.fault("Error force-refreshing token container: \(error, privacy: .public)\n \(newTokenContainer.refreshToken, privacy: .public)") | |||
throw TunnelError.startingTunnelWithoutAuthToken | |||
throw TunnelError.startingTunnelWithoutAuthToken(internalError: error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just taking advantage that there's underlying error info.
Task/Issue URL: https://app.asana.com/0/1207603085593419/1209322889682604/f macOS PR: duckduckgo/macos-browser#3829 BSK PR: duckduckgo/BrowserServicesKit#1213 **Description**: Fixes an issue where the tunnel is being stopped twice.
Task/Issue URL: https://app.asana.com/0/1207603085593419/1209322889682604/f iOS PR: duckduckgo/iOS#3928 BSK PR: duckduckgo/BrowserServicesKit#1213 **Description**: Fixes an issue where the tunnel is being stopped twice.
Task/Issue URL: https://app.asana.com/0/1207603085593419/1209322889682604/f
iOS PR: duckduckgo/iOS#3928
macOS PR: duckduckgo/macos-browser#3829
What kind of version bump will this require?: Patch
Description
Fixes an issue where the tunnel is being stopped twice.
Testing
Please refer to the platform-specific PRs for testing instructions.
Internal references:
Software Engineering Expectations
Technical Design Template