Skip to content
This repository has been archived by the owner on Mar 19, 2019. It is now read-only.

Don't log errors when client aborts the connection #110

Closed
danroth27 opened this issue Apr 12, 2015 · 9 comments
Closed

Don't log errors when client aborts the connection #110

danroth27 opened this issue Apr 12, 2015 · 9 comments
Assignees

Comments

@danroth27
Copy link
Member

Currently when you run the web command for the default ASP.NET 5 Web Site template you see errors whenever the client aborts the connection (ex you cancel the browser request). Clients aborting the connection is really an expected behavior and should not be logged as a server error.

Repro steps:

  • Create a new ASP.NET 5 Web Site
  • Switch to the web command and ctrl-F5
  • Browse to localhost:5000 but then cancel the request
  • A red error message with an IOException stack trace is displayed in the console output window
Started
error   : [Microsoft.AspNet.Server.WebListener.MessagePump] ProcessRequestAsync
System.IO.IOException ---> Microsoft.Net.Http.Server.WebListenerException: The s
pecified network name is no longer available
   --- End of inner exception stack trace ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot
ification(Task task)
   at Microsoft.AspNet.StaticFiles.StaticFileContext.<SendAsync>d__42.MoveNext()

--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot
ification(Task task)
   at Microsoft.AspNet.Diagnostics.Entity.DatabaseErrorPageMiddleware.<Invoke>d_
_6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNet.Diagnostics.Entity.DatabaseErrorPageMiddleware.<Invoke>d_
_6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot
ification(Task task)
   at Microsoft.AspNet.Diagnostics.ErrorPageMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNet.Diagnostics.ErrorPageMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot
ification(Task task)
   at Microsoft.VisualStudio.Web.BrowserLink.Runtime.BrowserLinkMiddleware.<Exec
uteWithFilter>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot
ification(Task task)
   at Microsoft.AspNet.Hosting.Internal.RequestServicesContainerMiddleware.<Invo
ke>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot
ification(Task task)
   at Microsoft.AspNet.Server.WebListener.MessagePump.<ProcessRequestAsync>d__19
.MoveNext()
@davidfowl
Copy link
Member

+1

@Tratcher
Copy link
Member

Warning?

@davidfowl
Copy link
Member

Debug

@Tratcher
Copy link
Member

For reference, this catch statement and logger are at the root of the request processing call-stack. You end up here if anything goes wrong during a request. At this point we will rarely know the cause of the exception.

Are you recommending we suppress logging all exceptions if we think the client has disconnected? That's why I recommended Warning.

@muratg muratg added this to the Backlog milestone Sep 9, 2015
@Tratcher
Copy link
Member

The stack trace is a little different now that WebListener has some buffering enabled by default:

01:29:55.8657 Error Flush
System.IO.IOException ---> Microsoft.Net.Http.Server.WebListenerException: The specified network name is no longer available
   --- End of inner exception stack trace ---
01:29:55.8901 Error ProcessRequestAsync
System.IO.IOException ---> Microsoft.Net.Http.Server.WebListenerException: The specified network name is no longer available
   --- End of inner exception stack trace ---
   at Microsoft.Net.Http.Server.ResponseStream.FlushInternal(Boolean endOfRequest)
   at Microsoft.Net.Http.Server.ResponseStream.Dispose(Boolean disposing)
   at System.IO.Stream.Close()
   at Microsoft.Net.Http.Server.Response.Dispose()
   at Microsoft.Net.Http.Server.RequestContext.Dispose()
   at Microsoft.AspNet.Server.WebListener.MessagePump.<ProcessRequestAsync>d__23.MoveNext()

The error now commonly happens after app code when flushing the buffer. It will be easier to de-emphasize errors in this scenario.

@Tratcher Tratcher removed this from the Backlog milestone Jul 13, 2016
@Tratcher Tratcher added the bug label Jul 13, 2016
@Tratcher Tratcher self-assigned this Jul 14, 2016
@Tratcher
Copy link
Member

Related: #173. If we suppress throwing write errors then we don't have to worry as much about logging them when caught later.

@muratg muratg added this to the 1.1.0 milestone Jul 14, 2016
@Tratcher
Copy link
Member

aspnet/StaticFiles#150

@Tratcher
Copy link
Member

Tratcher commented Sep 7, 2016

All the work in this repo has been completed. We'll work on StaticFiles separately.

@Tratcher Tratcher closed this as completed Sep 7, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants