Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/Http/LogStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -560,8 +560,18 @@ protected virtual void WriteLineInternal ( string line ) {
string lineText = NormalizeEntries ?
line.Normalize ().Trim ().ReplaceLineEndings () : line;

if (!_channel.Writer.TryWrite ( lineText )) {
throw new InvalidOperationException ( SR.LogStream_FailedWrite );
try {
_channel.Writer.WriteAsync ( lineText, _cancellationTokenSource.Token )
.AsTask ()
.ConfigureAwait ( false )
.GetAwaiter ()
.GetResult ();
}
catch (ChannelClosedException) {
// Channel was closed, which is expected during shutdown. Ignore.
}
catch (OperationCanceledException) when (_cancellationTokenSource.IsCancellationRequested) {
// Cancellation requested during shutdown. Ignore.
}
}

Expand Down Expand Up @@ -738,4 +748,4 @@ private sealed class FlushSignal {
public TaskCompletionSource<bool> Completion { get; } = new TaskCompletionSource<bool> ( TaskCreationOptions.RunContinuationsAsynchronously );
}
}
}
}
Loading