Unhandle exception crash the application
alexfdezsauco opened this issue · comments
Igr Alexánder Fernández Saúco commented
Bug Report
An "unhandled exception" cause the full application crash. The configuration include a requester and also allow javascript execution.
var requester = new HttpClientRequester(httpClient);
var config = Configuration.Default.WithRequester(requester).WithDefaultLoader(new LoaderOptions { IsResourceLoadingEnabled = true }).WithJs();
But a network issues cause the app crashes. Looks like the request occurs in an isolated thread and the program can't catch the exception.
Stack Trace:
Unhandled exception. System.Net.Http.HttpRequestException: Error while copying content to a stream.
---> System.IO.IOException: Received an unexpected EOF or 0 bytes from the transport stream.
at System.Net.Security.SslStream.<FillBufferAsync>g__InternalFillBufferAsync|215_0[TReadAdapter](TReadAdapter adap, ValueTask`1 task, Int32 min, Int32 initial)
at System.Net.Security.SslStream.ReadAsyncInternal[TReadAdapter](TReadAdapter adapter, Memory`1 buffer)
at System.Net.Http.HttpConnection.FillAsync()
at System.Net.Http.HttpConnection.CopyToContentLengthAsync(Stream destination, UInt64 length, Int32 bufferSize, CancellationToken cancellationToken)
at System.Net.Http.HttpConnection.ContentLengthReadStream.CompleteCopyToAsync(Task copyTask, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionResponseContent.SerializeToStreamAsync(Stream stream, TransportContext context, CancellationToken cancellationToken)
at System.Net.Http.HttpContent.LoadIntoBufferAsyncCore(Task serializeToStreamTask, MemoryStream tempBuffer)
--- End of inner exception stack trace ---
at System.Net.Http.HttpContent.LoadIntoBufferAsyncCore(Task serializeToStreamTask, MemoryStream tempBuffer)
at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
at AngleSharp.Io.Network.HttpClientRequester.PerformRequestAsync(Request request, CancellationToken cancel)
at AngleSharp.Io.BaseRequester.RequestAsync(Request request, CancellationToken cancel)
at AngleSharp.Io.BaseLoader.LoadAsync(Request request, CancellationToken cancel)
at AngleSharp.Browser.DefaultNavigationHandler.NavigateAsync(DocumentRequest request, CancellationToken cancel)
at AngleSharp.Dom.Document.LocationChanged(Object sender, ChangedEventArgs e)
at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__139_1(Object state)
at System.Threading.QueueUserWorkItemCallback.<>c.<.cctor>b__6_0(QueueUserWorkItemCallback quwi)
at System.Threading.ExecutionContext.RunForThreadPoolUnsafe[TState](ExecutionContext executionContext, Action`1 callback, TState& state)
at System.Threading.QueueUserWorkItemCallback.Execute()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
Florian Rappl commented
It should definitely be handled.
Mind trying to do a PR on this? Many thanks for reporting!
Igr Alexánder Fernández Saúco commented
Cloning ...