-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
[API Proposal]: Add transport error code to QuicException #87262
Comments
Tagging subscribers to this area: @dotnet/ncl Issue DetailsBackground and motivationRelated to #72666. Quic RFC (https://www.rfc-editor.org/rfc/rfc9000.html#name-transport-error-codes) defines set of error codes and we probably should surface them in cases when We already have API Proposalnamespace System.Net.Quic
{
public class QuicException
{
public System.Net.Quic.QuicError QuicError { get { throw null; } }
public long? ApplicationErrorCode { get { throw null; } }
+. public long? TransportErrorCode { get { throw null; }}
}
} API Usage try {
QuicConnection connection = await QuicConnection.ConnectAsync();
}
catch (QuicExeption ex)
{
log($"{ex.Message} Application error {ex.ApplicationErrorCode} transport error {ex.TransportErrorCode}");
} the transport errors are generally unrecoverable e.g. we do not expect separate code branches based on specific value. Alternative Designsnamespace System.Net.Quic
{
public class QuicException
{
public System.Net.Quic.QuicError QuicError { get { throw null; } }
- public long? ApplicationErrorCode { get { throw null; } }
+. public long? ErrorCode { get { throw null; }}
}
} We can unify the error code and the value would have meaning based on Since the error codes are applicable only ins some cases it may not make sense to drag nullable fields in al instances. namespace System.Net.Quic
{
public class QuicTransportException: QuicException
{
public System.Net.Quic.QuicError QuicError { get { throw null; } }
+. public long TransportErrorCode { get { throw null; }}
}
}
RisksNo response
|
Should part of this also be update of And please remind me why we decided not to do enum for the transport error codes? |
I can take closer look but I think the transport error surface as connection aborts. The questions is if we would want to change that. For the enums we felt that the value is low e.g. it is unlikely somebody would do anything besides logging for troubleshooting. And we do not needs to maintain it if there are updates in next Quic revision. |
I found cases when we throw InternalError so adding specific |
So there are multiple different cases when a transport error surfaces as something else. I know of:
Which extra case requires |
TLS-related stuff gets translated into TLS alert and @wfurt I see that there is
That would be the |
I saw I would rather have |
So how will that look? I'm looking at: runtime/src/libraries/System.Net.Quic/src/System/Net/Quic/QuicConnection.cs Lines 482 to 495 in c14f0c7
There is no special handling, we chose |
My intention is to pass in the transport code via nullable parameter and throw the exception in cases when set and when we did not handle it as special case discussed above. |
But ProtocolError also bubbles up from |
that would be fine with me. as far as I can tell there is no test case that would cover |
Looks good as proposed. The rename needs to be documented as a preview breaking change. namespace System.Net.Quic
{
public enum QuicError
{
// existing members omitted
- /// <summary>
- /// A QUIC protocol error was encountered.
- /// </summary>
- ProtocolError,
+ /// <summary>
+ /// Operation failed because peer transport error occurred.
+ /// </summary>
+ TransportError,
}
public class QuicException
{
public System.Net.Quic.QuicError QuicError { get { throw null; } }
public long? ApplicationErrorCode { get { throw null; } }
+. public long? TransportErrorCode { get { throw null; }}
}
} |
Added
Tagging @dotnet/compat for awareness of the breaking change. |
Background and motivation
Related to #72666. Quic RFC (https://www.rfc-editor.org/rfc/rfc9000.html#name-transport-error-codes) defines set of error codes and we probably should surface them in cases when
QuicConnection
fails for one of them.We already have
ProtocolError
to cover some cases when peer sends invalid data and it feels like there are also cases when the transport fail for other reasons. The proposal is to remove specificProtocolError
as Quic is still inPreview
and replace it it with more genericTransportError
.We already have
ApplicationErorrCode
inQuicException
so the proposal is to add alsoTransportErrorCode
API Proposal
API Usage
the transport errors are generally unrecoverable e.g. we do not expect separate code branches based on specific value.
Alternative Designs
We can unify the error code and the value would have meaning based on
QuicError
value. We generally felt this may be confusing and easy to make mistake and misinterpret the value.Since the error codes are applicable only ins some cases it may not make sense to drag nullable fields in al instances.
We can subtype
namespace System.Net.Quic { public class QuicTransportException: QuicException { public System.Net.Quic.QuicError QuicError { get { throw null; } } +. public long TransportErrorCode { get { throw null; }} } }
We also talk about making the
TransportErrorCode
strongly typed e.g. creatingenum
for it. But it is not clear how stableQuic
protocol is and we would need to keep up. Also RFC defines some ranges and that may be hard to map toenum
. Current plan is to surface the reason in some more friendly way in text when we know it.Risks
No response
The text was updated successfully, but these errors were encountered: