-
-
Notifications
You must be signed in to change notification settings - Fork 159
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
Resume alamofire request only and only if it hasn't been started previously #167
Conversation
Awesome! Thank you for taking this on. I’ll add a couple of minor project style consistency things in the review notes. It would be great to get regression tests for this. It’s subtle enough — and easy enough to mess up — that it’s worth covering. I take it that if |
@@ -56,7 +56,9 @@ internal struct AlamofireRequestNetworking: RequestNetworking, SessionTaskContai | |||
init(_ alamofireRequest: Alamofire.Request) | |||
{ | |||
self.alamofireRequest = alamofireRequest | |||
alamofireRequest.resume() // in case manager.startRequestsImmediately is false | |||
if case .suspended = self.alamofireRequest.task?.state ?? .suspended { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This project never uses superfluous self
.
@@ -56,7 +56,9 @@ internal struct AlamofireRequestNetworking: RequestNetworking, SessionTaskContai | |||
init(_ alamofireRequest: Alamofire.Request) | |||
{ | |||
self.alamofireRequest = alamofireRequest | |||
alamofireRequest.resume() // in case manager.startRequestsImmediately is false | |||
if case .suspended = self.alamofireRequest.task?.state ?? .suspended { | |||
alamofireRequest.resume() // in case manager.startRequestsImmediately is false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know the brace & indentation conventions of the project are weird, but please do follow them. Brace rules are at the end of the README, or you can just look around the project for examples.
I' not familiar with tests you have, also I haven't found siesta+alamofire tests at all...
As for Alamofire sources, task should not be nil. When we initializing the Request object we pass there a task (that could be nil). So possibly, if something went wrong while creating a URLSessionTask object than nil will be passed to |
The existing tests rerun a large subset of the tests serval times on CI using four different networking provider/setting combinations, making sure that all the different underlying providers result in the same Siesta behavior. We could add a fifth provider to that suite with
If you give me push access to your pull request, I can drop the test in the right place. |
@pcantrell This option is selected
|
I dug into this a bit, and decided that the substantial amount of code it would take to test the fix simply isn’t justified. Sorry for the long delay on accepting this, @piv199, and thanks again so much for chasing the issue down! Did you file an issue with Alamofire about the redundant notification? It really does seem like that’s a bug. |
fixes #163
Tested in the example with starts immediately true || false, now it's working as expected... So no second call for alamofire request resume method.