Skip to content

Commit

Permalink
Swallow exception when trying to complete the pipe reader
Browse files Browse the repository at this point in the history
This is to prevent an unhandled exception in the case when the cancellation token has not been flagged as cancelled but the pipe reader cannot read from the client. Ref #195
  • Loading branch information
smatsson committed Jan 5, 2023
1 parent 1c4c518 commit 2b18346
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Source/tusdotnet/Stores/TusDiskStore.PipeReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,13 @@ public async Task<long> AppendDataAsync(string fileId, PipeReader reader, Cancel
catch (Exception)
{
// Clear memory and complete the reader to not cause a Microsoft.AspNetCore.Connections.ConnectionAbortedException inside Kestrel later on as this is an "expected" exception.
reader.AdvanceTo(result.Buffer.End);
await reader.CompleteAsync();
try
{
reader.AdvanceTo(result.Buffer.End);
await reader.CompleteAsync();
}
catch { /* Ignore if we cannot complete the reader so that the real exception will propagate. */ }

throw;
}

Expand Down

0 comments on commit 2b18346

Please sign in to comment.