Skip to content
This repository has been archived by the owner on Jan 26, 2021. It is now read-only.

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

Open
jsm174 opened this issue Oct 4, 2019 · 2 comments
Open

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

jsm174 opened this issue Oct 4, 2019 · 2 comments

Comments

@jsm174
Copy link

jsm174 commented Oct 4, 2019

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?

@greenmood
Copy link

faced the same issue. Got no answer yet.

@greenmood
Copy link

For future searchers Alamofire/Alamofire#3213

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants