flagsmith-ios-client icon indicating copy to clipboard operation
flagsmith-ios-client copied to clipboard

HTTP load failed, 0/0 bytes (error code: -1009 [1:50])

Open 3a4oT opened this issue 1 year ago • 4 comments

We tried to use the latest release but discovered issues with URLSession loading on iOS. Considering that my internal fork (with strict concurrency changes) works well, I suspect something went wrong with other commits (maybe Privacy manifest??). I haven't had time to research so far.

Issue reported on the console when pointing to the 3.6.0 release:

nw_endpoint_handler_path_change [C6 edge.api.flagsmith.com:443 waiting parent-flow (satisfied (Path is satisfied), interface: en0[802.11], uses wifi)] blocked tracker
Connection 6: received failure notification
Connection 6: failed to connect 1:50, reason -1
Connection 6: encountered error(1:50)
Task <BAD4587C-xxx-xxxxx-xx-xxxxx>.<3> HTTP load failed, 0/0 bytes (error code: -1009 [1:50])
Task <BAD4587C-xx-xxx-xxxx-xx>.<3> finished with error [-1009] Error Domain=NSURLErrorDomain Code=-1009 "The internet connection appears to be offline." UserInfo={_kCFStreamErrorCodeKey=50, NSUnderlyingError=0x600000c9b420 {Error Domain=kCFErrorDomainCFNetwork Code=-1009 "(null)" UserInfo={_NSURLErrorBlockedTrackerFailureKey=true, _kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=50, _NSURLErrorNWPathKey=satisfied (Path is satisfied), interface: en0[802.11], uses wifi}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <xxxxxxx>.<3>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <xxxxxxxxxx>.<3>"
), NSLocalizedDescription=The internet connection appears to be offline., NSErrorFailingURLStringKey=https://edge.api.flagsmith.com/api/v1/identities/?identifier=xxxxxxxxx, NSErrorFailingURLKey=https://edge.api.flagsmith.com/api/v1/identities/?identifier=xxxxxxxx, _kCFStreamErrorDomainKey=1}

cc. @dabeeeenster , @gazreese

3a4oT avatar May 10 '24 13:05 3a4oT

Thanks @3a4oT, we will look into this. Could you update the title of the issue to better describe the issues that you're facing? Also, are you able to provide any further information about how to replicate this issue?

matthewelwell avatar May 10 '24 13:05 matthewelwell

Thanks @3a4oT, we will look into this. Could you update the title of the issue to better describe the problems that you're facing? Also, are you able to provide any further information about how to replicate this issue?

Just try to get flags, nothing special. It fails when loading from an iOS app (consuming from SPM), so I guess it may be related to NSAppTransportSecurity (again not sure how and why, yet :)))

3a4oT avatar May 10 '24 13:05 3a4oT

Hi @3a4oT do you have the tracking switch switched off for the app that you have Flagsmith integrated into?

If you go to Privacy and Security then Tracking in settings you should see a list of apps. Could you please try with and without for your app and let us know the outcome?

gazreese avatar May 10 '24 13:05 gazreese

Hi, we're seeing exactly the same issue. No changes made to how we're using the Flagsmith SDK, but pointing to 3.6.0 release results in us seeing the same error.

EmilSveaSolar avatar May 14 '24 09:05 EmilSveaSolar

Hi @3a4oT do you have the tracking switch switched off for the app that you have Flagsmith integrated into?

If you go to Privacy and Security then Tracking in settings you should see a list of apps. Could you please try with and without for your app and let us know the outcome?

My app is not on that list, but I guess you're digging in the right direction. It seems like the root cause of it is this change . Per Apple documentation seems like a network error is expected if the user doesn't allow tracking.


NSPrivacyTrackingDomains
An array of strings that lists the internet domains your app or third-party SDK connects to that engage in tracking. 
If the user has not granted tracking permission through the App Tracking Transparency framework, network requests to these domains fail and your app receives an error.

The issue is that SDK should continue to work no matter what the user chooses in terms of tracking.

3a4oT avatar May 22 '24 09:05 3a4oT

ahh, just saw your PR, so it seems like you come to the same conclusion. I will try to test your branch and see whether it helps.

3a4oT avatar May 22 '24 09:05 3a4oT

I can confirm that linked PR fixed the issue with network error.

3a4oT avatar May 22 '24 10:05 3a4oT