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

Some errors are ignored and not provided to the client in completion handlers #170

Closed
johnnewman opened this issue Nov 27, 2018 · 2 comments

Comments

@johnnewman
Copy link

johnnewman commented Nov 27, 2018

Using v0.10.0 or v0.10.1, if you try to reverse geocode in airplane mode, the completion handler is never called. This can be replicated using the following code:

MBGeocoder *geocoder = [[MBGeocoder alloc] initWithAccessToken:<token>];
MBReverseGeocodeOptions *options = [[MBReverseGeocodeOptions alloc] initWithCoordinate:anyCoordinate];
[geocoder geocodeWithOptions:options completionHandler:^(NSArray<MBGeocodedPlacemark *> * _Nullable placemarks, NSString * _Nullable attribution, NSError * _Nullable error) {
        
    // never hit with an error
      
}];

This line

guard let data = data else { return }
appears to be the culprit.

return URLSession.shared.dataTask(with: request) { (data, response, error) in

    guard let data = data else { return }
    ...

It returns immediately but the error object containing information about the network issue is ignored. Reproduced on iOS 12.0 and 12.1.

@1ec5
Copy link
Contributor

1ec5 commented Jan 23, 2019

I can reproduce this issue with any scenario that would result in a dataless response. By comparison, the analogous MapboxDirections.swift code is more robust, because the Directions API has a few such known edge cases: mapbox/mapbox-directions-swift#314.

/~https://github.com/mapbox/MapboxDirections.swift/blob/aa0e64bc10f1419b656c1fdae117a7c0d5f255b3/MapboxDirections/MBDirections.swift#L252-L258

@1ec5
Copy link
Contributor

1ec5 commented Jan 23, 2019

#175 has a fix for this issue.

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

No branches or pull requests

2 participants