kean / Pulse

Network logger for Apple platforms
https://pulselogger.com
MIT License
6.32k stars 302 forks source link

All requests are marked as Pending #212

Closed florinmatinca closed 1 month ago

florinmatinca commented 1 year ago

Hi guys, I still have this issue on the latest version of Pulse, without using async/await.

In my APIService class, I'm just enabling the logger with :

URLSessionProxyDelegate.enableAutomaticRegistration()

Then, all the requests are appearing in the Console, but with Pending. Should I implement manually any methods from URLSessionDelegate protocol ?

Originally posted by @florinmatinca in https://github.com/kean/Pulse/issues/153#issuecomment-1674464078

kean commented 11 months ago

Hi, @florinmatinca. Have you found a way to resolve it?

The integration method based on URLSessionProxyDelegate only works with delegate-based URLSessions.

yonicsurny commented 2 months ago

I too face this issue in my project and I do use delegate-based URLSession.

My project is quite old and is a mix of Swift and Objective-C (the networking module is in Objective-C). I tried integrating the frameworks in a "pure Swift" and in a "Objective-C with Swift" projects and faced no issue there.

So I'm puzzled by what could be the issue in my project. Any pointers?

yonicsurny commented 2 months ago

Ok, my bad, I did not read attentively the other issues and pull requests on the topic. I am also using the convenience dataTask(with:completionHandler:) function which does not call the delegate.

kean commented 2 months ago

I have a potential swizzling-based solution in the works, but in the meantime, all the available options are described here. The recommended approach is to use URLSessionProxyDelegate or log the requests manually as it's the most reliable way that is unlikely to break in the future.

yonicsurny commented 2 months ago

Yes, I went for the following and it is working nicely.

#if !PROD
Experimental.URLSessionProxy.shared.isEnabled = true
Experimental.swizzleURLSession()
#endif

This is ok because I'm not integrating Pulse into my production build. It will only be used for debug and staging builds.

Thank you very much for your work.

kean commented 1 month ago

Closing as duplicate of https://github.com/kean/Pulse/issues/113. Fixed shiped in Pulse 5.0