Error when setting session `AF.session` for `OIDURLSessionProvider.setSession` to no events corresponding to task found.: file Alamofire/RequestTaskMap.swift, line 117
Nobody has claimed this yet.
- Dominant language
- Objective-C
- Stars
- 2k
- Forks
- 867
- Avg merge
- 4d 48m
- Merged PRs (30d)
- 1
Description
Are you filing an issue about iOS 12?
No
Describe the bug
When using an Alamofire AF.session with OIDURLSessionProvider.setSession() an underlying task is not created with Alamofires RequestTaskMap
To Reproduce
Steps to reproduce the behavior:
- Create project with Alamofire 5.4.0 and AppAuth 1.40 installed via cocoa pods
- Set
OIDURLSessionProvider.setSession(AF.session) - Call either
OIDAuthorizationService.discoverConfigurationorOIDAuthState.authState(byPresenting:tokenExchangeAdditionalParameters: presenting:callback:
The RequestTaskMap is expecting to have a task populated in its task map, but results in the error:
Fatal error: RequestTaskMap consistency error: no events corresponding to task found.: file Alamofire/RequestTaskMap.swift, line 117
Expected behavior
The RequestTaskMap should have a populated task map and not result in an error when using Alamofires URLSession session.
Desktop (please complete the following information):
- OS: macOS
- Browser Safari
- Version 10.15.7
Smartphone (please complete the following information):
- Device: Simulator
- OS: iOS 14.3
- Browser safari
- Version 1.4.0
Additional context
This only happens when I use Alamofire v5.0.0+ regardless of which AppAuth version I use (I was on 0.92.0 when this bug was discovered).
This may not be an AppAuth issue but I believe the source of this error is happening at
[session dataTaskWithURL:url
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
In OIDAuthorizationService.m methods discoverServiceConfigurationForDiscoveryURL or performTokenRequest:.
Note: If I pass OIDURLSessionProvider.setSession(URLSession.shared) then this error does not happen.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with Alamofire/RequestTaskMap.swift at line 117 and trace how OIDURLSessionProvider.setSession(AF.session) interacts with OIDAuthorizationService.m, especially discoverServiceConfigurationForDiscoveryURL and performTokenRequest:. Reproduce with Alamofire 5.4.0 and AppAuth using AF.session, then compare with URLSession.shared. Done means the reported flow no longer triggers the RequestTaskMap consistency error and the task map is populated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- objective-c, swift
- Domain
- authentication, mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100