Skip to content
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

The underlying Task is already in one of the three final states: RanToCompletion, Faulted, or Canceled. #1

Closed
oliverw opened this issue Oct 5, 2013 · 4 comments

Comments

@oliverw
Copy link

oliverw commented Oct 5, 2013

Occurs from time to time in AFNetworkHandler.cs:87 and I haven't yet figured why and when. But brings down the application when it occurs.

2013-10-05 20:53:29.961 GIFE[17563:c07] Unhandled managed exception: The underlying Task is already in one of the three final states: RanToCompletion, Faulted, or Canceled. (System.InvalidOperationException)
  at System.Threading.Tasks.TaskCompletionSource`1[AFNetworking.AFHTTPRequestOperation].ThrowInvalidException () [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Threading.Tasks/TaskCompletionSource.cs:91 
  at System.Threading.Tasks.TaskCompletionSource`1[AFNetworking.AFHTTPRequestOperation].SetException (IEnumerable`1 exceptions) [0x0000c] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Threading.Tasks/TaskCompletionSource.cs:80 
  at System.Threading.Tasks.TaskCompletionSource`1[AFNetworking.AFHTTPRequestOperation].SetException (System.Exception exception) [0x00011] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Threading.Tasks/TaskCompletionSource.cs:74 
  at ModernHttpClient.AFNetworkHandler+<enqueueOperation>c__AnonStorey2.<>m__1 (AFNetworking.AFHTTPRequestOperation op, MonoTouch.Foundation.NSError err) [0x00037] in /Users/oliver/Projects/ModernHttpClient/src/ModernHttpClient.iOS/AFNetworkHandler.cs:87 
  at MonoTouch.ObjCRuntime.Trampolines+SDAFHttpRequestFailureCallback.Invoke (IntPtr block, IntPtr operation, IntPtr error) [0x00061] in /Users/oliver/Projects/ModernHttpClient/vendor/afnetworking/AFNetworking/obj/Debug/ios/ObjCRuntime/Trampolines.g.cs:185 
  at (wrapper native-to-managed) MonoTouch.ObjCRuntime.Trampolines/SDAFHttpRequestFailureCallback:Invoke (intptr,intptr,intptr)
  at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38 
  at GIFE.Application.Main (System.String[] args) [0x00009] in /Users/oliver/Projects/GIFE/IOS/GIFE/Main.cs:18 
@anaisbetts
Copy link
Owner

Think b689234 takes care of this but I have no idea, can you give it a shot?

@oliverw
Copy link
Author

oliverw commented Oct 6, 2013

Could have been caused by using this overload:

SendAsync(msg, HttpCompletionOption.ResponseHeadersRead)

@alexshikov
Copy link
Contributor

I do experience the same issue.

I didn't figure out the reason of the issue yet, but the fix is simple:
change SetResult, SetException, SetCanceled inside the method enqueueOperation
to TrySetResult, TrySetException, TrySetCanceled

I believe b689234 can be reverted then.

@anaisbetts
Copy link
Owner

This should be fixed now, reopen it if it's not

markmario referenced this issue in dnstech/ModernHttpClient Feb 16, 2018
Half Wolf-5867: Fix automated test config
markmario referenced this issue in dnstech/ModernHttpClient Feb 16, 2018
gtbX pushed a commit to perfectco/ModernHttpClient that referenced this issue Mar 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants