Inumedia / SlackAPI

.NET Implementation of the Slack team communication platform API.
MIT License
452 stars 243 forks source link

Null Reference Exception #109

Closed ghost closed 6 years ago

ghost commented 7 years ago

Sometimes I got this stack trace from event viewer. My application crashes and there is no way back. I also created a stackoverflow question for this.

Here is the stack trace from windows event viewer:

Application: X.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.NullReferenceException
   at SlackAPI.RequestState`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].GotResponse(System.IAsyncResult)
   at System.Net.LazyAsyncResult.Complete(IntPtr)
   at System.Net.ContextAwareResult.CompleteCallback(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Net.ContextAwareResult.Complete(IntPtr)
   at System.Net.LazyAsyncResult.ProtectedInvokeCallback(System.Object, IntPtr)
   at System.Net.HttpWebRequest.SetResponse(System.Exception)
   at System.Net.HttpWebRequest.SetAndOrProcessResponse(System.Object)
   at System.Net.ConnectionReturnResult.SetResponses(System.Net.ConnectionReturnResult)
   at System.Net.Connection.CompleteConnectionWrapper(System.Object, System.Object)
   at System.Net.PooledStream.ConnectionCallback(System.Object, System.Exception, System.Net.Sockets.Socket, System.Net.IPAddress)
   at System.Net.ServicePoint.ConnectSocketCallback(System.IAsyncResult)
   at System.Net.LazyAsyncResult.Complete(IntPtr)
   at System.Net.ContextAwareResult.Complete(IntPtr)
   at System.Net.LazyAsyncResult.ProtectedInvokeCallback(System.Object, IntPtr)
   at System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)
   at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)

Faulting application name: X.exe, version: 1.5.0.0, time stamp: 0x5914053a
Faulting module name: unknown, version: 0.0.0.0, time stamp: 0x00000000
Exception code: 0xc0000005
Fault offset: 0x0655a904
Faulting process id: 0x1bb0
Faulting application start time: 0x01d2ca214de3853b
Faulting application path: PATH-TO-X.exe
Faulting module path: unknown
Report Id: 5ef2a70f-387a-11e7-9c66-000c29bbc8ee
Inumedia commented 7 years ago

Could you try with 21bdc496f7751406f67f3bb66759c3572a2ef894 and see if it still happens?

ghost commented 7 years ago

Sure, But because it's production environment it may take a while.

Inumedia commented 7 years ago

No worries, my hunch is that a request is timing out and response is coming back as null. So if we don't get a response I'll just let the exception bubble up so it will give the proper exception type. As for handling it, I'm not super sure how to implement that yet and will likely need to be a much larger change.

ghost commented 7 years ago

Yeah, maybe. I use Slack API in an async method so I thought throwing an exception should make just a task become failed. But it takes down the entire application. By the way thank you for the API. It has been helped me a lot.

ghost commented 7 years ago

Yesterday the error happened again. Pulled and added the commit to the application. I will inform you of any further events.

ghost commented 7 years ago

Hi @Inumedia, After 4 days there is no sign of old error. Thanks for the patch.

ghost commented 7 years ago

I got another kind of exception which I think is related to the one I had before. Would you please have a look at this one:

Application: X.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.Net.Sockets.SocketException at System.Net.Sockets.Socket.EndConnect(System.IAsyncResult) at System.Net.ServicePoint.ConnectSocketInternal(Boolean, System.Net.Sockets.Socket, System.Net.Sockets.Socket, System.Net.Sockets.Socket ByRef, System.Net.IPAddress ByRef, ConnectSocketState, System.IAsyncResult, System.Exception ByRef)

Exception Info: System.Net.WebException at SlackAPI.RequestState`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].GotResponse(System.IAsyncResult) at System.Net.LazyAsyncResult.Complete(IntPtr) at System.Net.ContextAwareResult.CompleteCallback(System.Object) at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) at System.Net.ContextAwareResult.Complete(IntPtr) at System.Net.LazyAsyncResult.ProtectedInvokeCallback(System.Object, IntPtr) at System.Net.HttpWebRequest.SetResponse(System.Exception) at System.Net.HttpWebRequest.SetAndOrProcessResponse(System.Object) at System.Net.ConnectionReturnResult.SetResponses(System.Net.ConnectionReturnResult) at System.Net.Connection.CompleteConnectionWrapper(System.Object, System.Object) at System.Net.PooledStream.ConnectionCallback(System.Object, System.Exception, System.Net.Sockets.Socket, System.Net.IPAddress) at System.Net.ServicePoint.ConnectSocketCallback(System.IAsyncResult) at System.Net.LazyAsyncResult.Complete(IntPtr) at System.Net.ContextAwareResult.Complete(IntPtr) at System.Net.LazyAsyncResult.ProtectedInvokeCallback(System.Object, IntPtr) at System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32, UInt32, System.Threading.NativeOverlapped) at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32, UInt32, System.Threading.NativeOverlapped)

RyanMathewson commented 7 years ago

I just encountered the same issue @miladamirzadeh originally posted while using the v1.0.5.93 NuGet package. Will the package be updated to include the patch any time soon?

vonzepp commented 7 years ago

Hello, Is it possible to merge this fix and update nuget package, please?

gpailler commented 6 years ago

1.0.7 released