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

Surface specific XPC & login item errors #819

Merged
merged 22 commits into from
Jun 4, 2024
Merged

Conversation

quanganhdo
Copy link
Member

@quanganhdo quanganhdo commented May 14, 2024

Required:

Task/Issue URL: https://app.asana.com/0/72649045549333/1207013105069620/f
iOS PR:duckduckgo/iOS#2872
macOS PR: duckduckgo/macos-browser#2773
What kind of version bump will this require?: Minor

Optional:

Tech Design URL:
CC:

Description:

Steps to test this PR:

  1. See platform-specific PRs

OS Testing:

  • iOS 14
  • iOS 15
  • iOS 16
  • macOS 10.15
  • macOS 11
  • macOS 12

Internal references:

Software Engineering Expectations
Technical Design Template

@samsymons samsymons self-requested a review May 15, 2024 04:24
@quanganhdo quanganhdo marked this pull request as ready for review May 16, 2024 03:29
Copy link
Contributor

@diegoreymendez diegoreymendez left a comment

Choose a reason for hiding this comment

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

Added some comments as I think there's some space for developer quality-of-life improvements.

import Foundation

@objc
final public class KnownFailure: NSObject, Codable {
Copy link
Contributor

Choose a reason for hiding this comment

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

This forces all errors that are "known" to be defined in BSK which seems unnecessarily restrictive.

Why instead not just make the error adhere to Codable and store that in NetworkProtectionKnownFailureStore.

Then the VPN app can decide what errors are worth passing over IPC, but at least we don't have to add errors that are macOS specific to BSK.

Copy link
Member Author

Choose a reason for hiding this comment

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

Why instead not just make the error adhere to Codable and store that in NetworkProtectionKnownFailureStore.

It's tricky as we need a concrete type to decode the error; and that type needs to be passed around in different ways (e.g. as part of XPCClientInterface, distributed notification object).

To keep it simple, I've moved the custom handling code for TunnelError outside of the initializer and instead made it so that an error conforming to InternalErrorWrapping can expose its internal error. That way we can keep specific errors outside of BSK.

Copy link
Contributor

Choose a reason for hiding this comment

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

Understood.

That said, I do think that instead of encoding domain, code and localizedDescription, we should turn this into a Codable enum. See this comment for context.

Copy link
Contributor

@diegoreymendez diegoreymendez left a comment

Choose a reason for hiding this comment

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

Added one request for a change.

import Foundation

@objc
final public class KnownFailure: NSObject, Codable {
Copy link
Contributor

Choose a reason for hiding this comment

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

Understood.

That said, I do think that instead of encoding domain, code and localizedDescription, we should turn this into a Codable enum. See this comment for context.

@quanganhdo quanganhdo merged commit 79fe0c9 into main Jun 4, 2024
9 checks passed
@quanganhdo quanganhdo deleted the anh/netp/error-ui branch June 4, 2024 13:38
quanganhdo added a commit to duckduckgo/macos-browser that referenced this pull request Jun 4, 2024
Task/Issue URL:
https://app.asana.com/0/72649045549333/1207013105069620/f
Tech Design URL:
CC:

BSK PR: duckduckgo/BrowserServicesKit#819

**Description**:

**Steps to test this PR**:
1. For the UI, go to Debug > VPN > Simulate known failure and check the
warning banner in the VPN popover
2. To check if XPC errors are surfaced, go to
`NetworkProtectionIPCTunnelController.start()`, and add a simulated
error like `handleFailure(NSError(domain: "SMAppServiceErrorDomain",
code: 1))` inside `handleFailure(_:)`
3. To check if login item version mismatch is handled, go to
`TunnelControllerIPCService.register(version:bundlePath:completion)` and
change the `DefaultIPCMetadataCollector.version != version` to
`DefaultIPCMetadataCollector.version == version`
4. To check if ClientError code 5 is handled, block access to NetP
endpoint (at router level or using Proxyman), then try to start the VPN.
5. Use Debug > VPN > Log metadata to console to check if
lastKnownFailureDescription is recorded
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.

3 participants