Closed ionmincu closed 7 months ago
@ionmincu, could you add more info like the underlaying operating system, SqlClient version and if it's an issue starting from a specific SqlClient version, besides providing a simple console app to repro the issue?
See te attached zip file for repro project. Or inline here:
Basically in 5.1.5 the message was not localized, and in 5.2.0 it is localized to the request locale. We would like it if this message is not localized, or it should have some specific error code to be able to ignore it in alerts.
OS:
Note the relationship with #26 - at least for async operations, SqlClient should be throwing TaskCanceledException which is the standard way to indicate cancellation.
TaskCanceledException
would be fine, but I understand that this might be seen as a major breaking change.
I mostly see 5.2 making a breaking change from 5.1.5 (by translating exception messages). I would be satisfied with one of the 2 solutions (that could be implemented quickly in a minor release):
Operation Canceled
exceptionWe are seeing the same issue while using Aspire (not Aspire specific) when running on Linux (at least WSL) and MacOS (customer reported). https://github.com/dotnet/aspire/issues/1023#issuecomment-2027844575
@sebastienros and reverting to 5.1.5 "fixes" this?
@ErikEJ I didn't realize this was specific to a new version and only focused on the "no specific error code", I will try to confirm that, if not I will file another issue.
Can still repro with 5.1.5, filing a new issue
@sebastienros Looking forward to your repro details
@ErikEJ did you check my repo details it should be the same thing for 5.1.5, just replace the version.
The thrown exception can be improved by including a more specific inner exception, such as TaskCanceledException
as @roji mentioned, and/or avoiding the translation of the message "Operation canceled by user".
The first part is a duplicate of issue #26, and the second part can be included in it.
cc @David-Engel
@DavoudEshtehari note that the standard behavior wouldn't be to include TaskCanceledException as an inner exception, but rather to throw a TaskCanceledException (as the top-level exception). This is important as various code reacts differently when a TaskCanceledException is thrown (as opposed to other types). For example, if a Task is terminated because of a TaskCanceledException, its state is Canceled rather than Faulted.
So just throwing TaskCanceledException would be the standard behavior here.
@roji Thanks for the clarification. @ionmincu I'll close this issue, but feel free to continue the discussion here or on the related issue #26.
@DavoudEshtehari that issue seems to be very old. I'm talking about an issue that was introduce recently in 5.2. Can we get some kind of disable translations feature for 5.3 ?
@ionmincu This behavior is identical to .NET Framework, and you've encountered it because of adding support for localization in .NET as well. Unfortunately, there is no easy way to switch it off.
Is your feature request related to a problem? Please describe.
In MDS 5.2 when
Operation canceled by user
occurs there is no way to tell from the exception that the operation was canceled. We can't just look at the token, the application is huge, and we are using ApplicationInsights to track exceptions usingITelemetryProcessor
to add custom dimentions on which exceptions to ignore.Now because the exception message is Localized we can't reliably tell if the operation was from a canceled token. For example when the Current culture to
ja
.Describe the solution you'd like
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
How to repro
See te attached zip file for repro project. Or inline here:
Expand code example
### EfExample.csproj ```xmlAdditional context
ErikEJ.EntityFramework.SqlServer
Stacktrace.