ApolloAlamofire icon indicating copy to clipboard operation
ApolloAlamofire copied to clipboard

Task nil when using Alamofire 5.0.0.rc2 - requires a delay

Open jsm174 opened this issue 6 years ago • 2 comments

I realize Alamofire 5 is not yet out, but when doing some testing with 5.0.0.rc2, a GraphQL request will result in a crash:

return request.responseJSON { response in
.
.
.
}.task!

Unexpectedly found nil while unwrapping an Optional value

After running through the debugger, task isn't always created right away.

As a temporary hack solution, I added a usleep:

 let request = sessionManager
                .request(url, method: .post, parameters: body,
                         encoding: JSONEncoding.default, headers: headers)
                .validate(statusCode: [200])
            
 usleep(500)
            
 if loggingEnabled {
    debugPrint(request)
 }

Has anyone else experienced this?

jsm174 avatar Oct 04 '19 17:10 jsm174

faced the same issue. Got no answer yet.

greenmood avatar Jun 03 '20 11:06 greenmood

For future searchers https://github.com/Alamofire/Alamofire/issues/3213

greenmood avatar Jun 03 '20 12:06 greenmood