Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include an error message payload alongside ChannelTerminated frames #536

Merged
merged 3 commits into from
Dec 17, 2022

Conversation

sarda-devesh
Copy link
Contributor

@sarda-devesh sarda-devesh commented Sep 26, 2022

Closes #299

Copy link
Collaborator

@AArnott AArnott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. This is looking better and simpler.

test/Nerdbank.Streams.Interop.Tests/Program.cs Outdated Show resolved Hide resolved
src/Nerdbank.Streams/MultiplexingStream.cs Outdated Show resolved Hide resolved
src/Nerdbank.Streams/MultiplexingStream.cs Outdated Show resolved Hide resolved
src/Nerdbank.Streams/MultiplexingStream.cs Outdated Show resolved Hide resolved
src/Nerdbank.Streams/MultiplexingStream.cs Outdated Show resolved Hide resolved
if (ex is OperationCanceledException && this.DisposalToken.IsCancellationRequested)
{
await mxStreamIOReader!.CompleteAsync().ConfigureAwait(false);
traceMessage = string.Format("Swallowed exception inside ProcessOutboundAsync: {0}", ex.Message);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused as to why you wrote this. Swallowing an exception means we don't re-throw it. But we do (still) rethrow it below, at the end of the catch block. It looks like you were saying this because you wouldn't be forwarding this exception to the remote party, so maybe say that? But that said, we should be careful about swallowing anything, because even an OperationCancelledException may be something we need to forward to the remote party. Really, anything that could possibly cast doubt on the quality of the data (including possible truncation) should be communicated as an exception.

And BTW, we should always specify a CultureInfo as a first argument to string.Format. For trace messages, using CultureInfo.InvariantCulture is probably appropriate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the second point that you made, that makes sense. For the first point that you made, I remember us discussing at the start of the project that we don't want to transmit errors where ex is OperationCanceledException && this.DisposalToken.IsCancellationRequested to the remote side which is why I introduced that. For now, I have gotten rid of that if statement and moving from the else statement into the catch block.

src/Nerdbank.Streams/MultiplexingStream.Channel.cs Outdated Show resolved Hide resolved
if (this.TraceSource!.Switch.ShouldTrace(TraceEventType.Information))
{
this.TraceSource.TraceEvent(
TraceEventType.Information,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Information level messages to communicate a TraceEventId.FatalError seems ironic. But this isn't a fatal error. At least, IIRC, the FatalError code indicates the MultiplexingStream as a whole is going down, but it isn't. Just this channel is. Maybe we should define a new ChannelFatalError code? And then use an TraceEventType.Error level for it here.

Copy link
Contributor Author

@sarda-devesh sarda-devesh Oct 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to introduce the ChannelFatalError code for just this one case. I am not sure what you generally consider a valid enough threshold for introducing a new code. Till then I have changed it to be of error level fatal and a code of zero.

src/Nerdbank.Streams/MultiplexingStream.Channel.cs Outdated Show resolved Hide resolved
src/Nerdbank.Streams/MultiplexingStream.Channel.cs Outdated Show resolved Hide resolved
@AArnott AArnott changed the title [wip] Include an error message payload alongside ChannelTerminated frames Include an error message payload alongside ChannelTerminated frames Dec 17, 2022
@AArnott AArnott added this to the v2.10 milestone Dec 17, 2022
Copy link
Collaborator

@AArnott AArnott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your latest iteration looks really good. I did a force push to squash your commits and add one of my own to clean up a bit. I'll merge as soon as the PR checks pass.

@AArnott AArnott enabled auto-merge December 17, 2022 23:23
@AArnott AArnott merged commit 9453508 into dotnet:main Dec 17, 2022
AArnott added a commit that referenced this pull request Jun 20, 2023
The new feature added in #536 that communicates channel failures to the remote party also caused channels to report failure if their owner `MultiplexingStream` was disposed of before the channel was. This broke several tests in the vs-servicehub repo and could theoretically break shipping code as well.
In this change I hide this particular behavioral change behind a setting that requires opt-in.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MultiplexingStream should transmit error condition that shuts down channels
2 participants