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

Fire event on matches api request failure #1176

Merged
merged 4 commits into from
Jan 22, 2025
Merged

Conversation

mallexxx
Copy link
Collaborator

@mallexxx mallexxx commented Jan 21, 2025

Please review the release process for BrowserServicesKit here.

Required:

Task/Issue URL: https://app.asana.com/0/1202406491309510/1209190998168436/f
iOS PR:
macOS PR:
What kind of version bump will this require?: Minor

Description:

  • Reduce Matches API default timeout to 5sec
  • Fire pixel event for timeout (and error, not to be matched on the client side for now)

Steps to test this PR:

  1. Connect over cellular with bad condition (or use network conditioner, or set the default timeout to a lower value)
  2. Visit some website, validate the timeout pixel is fired (in the app pixels log)

OS Testing:

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

Internal references:

Software Engineering Expectations
Technical Design Template

Copy link
Contributor

@alessandroboron alessandroboron left a comment

Choose a reason for hiding this comment

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

@mallexxx code looks good to me so I’m approving it!

I tried to test it using the network link conditioner and changing the time interval, but I could not get the session to fail with URLError.timedOut. We can sync if you want

@mallexxx
Copy link
Collaborator Author

mallexxx commented Jan 22, 2025

Yes, it required a bit more effort to reproduce, sorry: disabling local filter set search at MaliciousSiteDetector.swift:113:119 and setting up custom environment like this:

struct Env: MaliciousSiteProtection.APIClientEnvironment {
    func headers(for requestType: MaliciousSiteProtection.APIRequestType) -> Networking.APIRequestV2.HeadersV2 {
        MaliciousSiteDetector.APIEnvironment.production.headers(for: requestType)
    }
    func url(for requestType: MaliciousSiteProtection.APIRequestType) -> URL {
        MaliciousSiteDetector.APIEnvironment.production.url(for: requestType)
    }
    func timeout(for requestType: APIRequestType) -> TimeInterval? {
        switch requestType {
        case .matches(let matches):
            0.5
        default: MaliciousSiteDetector.APIEnvironment.production.timeout(for: requestType)
        }
    }
}

but in the end I‘ve got the error:
Screenshot 2025-01-22 at 14 48 22

@mallexxx mallexxx merged commit 1260917 into main Jan 22, 2025
7 checks passed
@mallexxx mallexxx deleted the alex/malsite-timeout-pixel branch January 22, 2025 08:52
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