Moya / Moya

Network abstraction layer written in Swift.
https://moya.github.io
MIT License
15.12k stars 1.99k forks source link

MoyaProvider+Internal.swift prints an error in the console from sendRequest #1188

Closed plam4u closed 7 years ago

plam4u commented 7 years ago

Hi there,

I'm calling a request using Moya and I see these errors in the console:

Jul 26 16:54:40  MyApp[87616] <Error>: +++++ HOLE: real delegate responds but we don't: 'URLSession:task:didFinishCollectingMetrics:'
Jul 26 16:54:40  MyApp[87616] <Error>: +++++ HOLE: real delegate responds but we don't: 'URLSession:task:didFinishCollectingMetrics:'

From Podfile.lock

  - Moya (8.0.4):
    - Moya/Core (= 8.0.4)
  - Moya/Core (8.0.4):
    - Alamofire (~> 4.1)
    - Result (~> 3.0)

I've spent some time to narrow down where the log message is coming from and it seems that the source is this method from MoyaProvider+Internal.swift:

    func sendRequest(_ target: Target, request: URLRequest, queue: DispatchQueue?, progress: Moya.ProgressBlock?, completion: @escaping Moya.Completion) -> CancellableToken {
        let initialRequest = manager.request(request as URLRequestConvertible)
        let alamoRequest = target.validate ? initialRequest.validate() : initialRequest
        return sendAlamofireRequest(alamoRequest, target: target, queue: queue, progress: progress, completion: completion)
    }

And more specifically this line in Moya:

let initialRequest = manager.request(request as URLRequestConvertible)

Seeing this error in the console worries me. Also, it's true that this message is printed by Alamofire, but maybe you know more about it. The API that I'm calling works.

Should I be worried? How can I fix this error?

sunshinejr commented 7 years ago

Hey @plam4u. Thanks for an issue!

I must admit that this is the first time I'm seeing this error and so my comment may not be useful at all. But, from my googling, I found 2 projects that use this error log and both use really similar codebase (there and there).

Are you sure these errors are from Alamofire? I'm not seeing anything like that in their sources but maybe I just didn't search enough 😄

plam4u commented 7 years ago

Hey @sunshinejr. This is what I did as well - Do a Google Search and see where is it coming from. I found the same 2 sources. The weird thing is that I don't use neither of them.

I was debugging step by step and after jumping through this line of Alamofire the log message appeared. I didn't find the log message in the source code of Alamofire.

Another thing that I've tried is to use Alamofire directly to load the exact same endpoint request and I didn't see any log messages.

It's a mystery to me. For now, I stopped the integration of Moya in the project until I resolve that since it's worrying me and my manager is very strict with warnings and error log messages or warning log messages.

Thank you for looking into that :) My guess is that since this is something new, it will pass sometime till somebody else asks or resolves the issue.

stale[bot] commented 7 years ago

This issue has been marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

stale[bot] commented 7 years ago

This issue has been auto-closed because there hasn't been any activity for 59 days. However, we really appreciate your contribution, so thank you for that! 🙏 Also, feel free to open a new issue if you still experience this problem 👍.

gowda57 commented 2 years ago

@plam4u Is this resolved??

ashishkanani commented 11 months ago

Hey @plam4u, Seems like you're using an analytics or other framework that is interposing itself into the URLSession that Alamofire uses under the hood. You need to find out where it comes from, as it seems like it doesn't properly implement the URLSessionTaskMetrics delegate method, causing the error. Perhaps there's an update for that framework that fixes the issue, or you can report the issue to get it fixed.