-
-
Notifications
You must be signed in to change notification settings - Fork 317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: the pending status issue #227
Conversation
completionHandler
Hey, @eligutovsky. That's a neat idea, and I appreciate you taking a stab at it! It's been a major pain-point when integrating Pulse. Are the response data and let data = context.data |
Hi @kean, I wanted to update you regarding the
I wanted to update you on the situation. Maybe you have any suggestions for improving this PR to meet the goal with the |
I haven't invested much time looking into the async/await and/or completion handler support. The recommended approach so far has been using the experimental proxy based on a custom URL protocol or logging manually. I'm not a fan of the solution based on a custom protocol, hence why it never exited the "experimental" status. There is likely a less invasive way to implement this with more swizzling. Proxyman went a bit further with swizzling in Atlantis – you may want to check it out. I briefly looked into it but ended up not following their approach and preferring the simplicity over the slight inconvenience during the setup process. |
Unfortunately, the "experimental solution" does not work well enough for a project that I'm working on 😔 Thank you @kean |
Description
This pull request proposes a solution for requests with 'Pending' status that never ends.
Issue
The issue arises when using
dataTask(with:completionHandler:)
with a non-nilcompletionHandler
. In this case, the delegate methodurlSession(:task:didCompleteWithError:)
will not be called. Apple's documentation describes this behavior.The description does not explicitly convey the behavior, but it provides some context.
Solution
The idea is to move the completion of a network task to
urlSession(:task:didFinishCollecting:)
method, by copying the implementation ofurlSession(:task:didCompleteWithError:)
.As the next step, I would like to kindly request your professional opinion regarding the potential implementation of the
urlSession(:task:didCompleteWithError:)
method for use in theurlSession(:task:didFinishCollecting:)
operation. Your valuable insights on this matter would be greatly appreciated.Connected issues and discussions:
Bonus
This solution solves
async/await
support