Closed Stra1ghter closed 2 years ago
Yea, now with EF7 we can look to see what they have actually changed. I thought they promised that this would no longer be a thrown exception. I was hoping it'd just stop being an exception and they would just log instead. But maybe that's not what they ended up doing (which would be unfortunate).
Maybe I'm doing something wrong, but these look the same to me. Oh, ok... I guess the error that the Query
class emitted is now gone. But the rest are still there (mainly due to being thrown?). Not sure if this really helps anything.
.NET 6
[15:35:11 Debug] Duende.IdentityServer.Endpoints.DiscoveryEndpoint
Start discovery request
[15:35:12 Error] Microsoft.EntityFrameworkCore.Database.Connection
An error occurred using the connection to database 'Duende.EntityFramework-6.1.0' on server '(localdb)\mssqllocaldb'.
[15:35:12 Error] Microsoft.EntityFrameworkCore.Query
An exception occurred while iterating over the results of a query for context type 'Duende.IdentityServer.EntityFramework.DbContexts.PersistedGrantDbContext'.
System.Threading.Tasks.TaskCanceledException: A task was canceled.
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternalAsync(Boolean errorsExpected, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternalAsync(Boolean errorsExpected, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenAsync(CancellationToken cancellationToken, Boolean errorsExpected)
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
System.Threading.Tasks.TaskCanceledException: A task was canceled.
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternalAsync(Boolean errorsExpected, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternalAsync(Boolean errorsExpected, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenAsync(CancellationToken cancellationToken, Boolean errorsExpected)
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
[15:35:12 Fatal] Duende.IdentityServer.Hosting.IdentityServerMiddleware
Unhandled exception: A task was canceled.
System.Threading.Tasks.TaskCanceledException: A task was canceled.
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternalAsync(Boolean errorsExpected, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternalAsync(Boolean errorsExpected, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenAsync(CancellationToken cancellationToken, Boolean errorsExpected)
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToArrayAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
at Duende.IdentityServer.EntityFramework.Stores.SigningKeyStore.LoadKeysAsync() in C:\ballen\work\Duende\github\IdentityServer\src\EntityFramework.Storage\Stores\SigningKeyStore.cs:line 64
at Duende.IdentityServer.Services.KeyManagement.KeyManager.GetAllKeysFromStoreAsync(Boolean cache) in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Services\Default\KeyManagement\KeyManager.cs:line 428
at Duende.IdentityServer.Services.KeyManagement.KeyManager.GetAllKeysInternalAsync() in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Services\Default\KeyManagement\KeyManager.cs:line 108
at Duende.IdentityServer.Services.KeyManagement.KeyManager.GetAllKeysAsync() in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Services\Default\KeyManagement\KeyManager.cs:line 95
at Duende.IdentityServer.Services.KeyManagement.AutomaticKeyManagerKeyStore.GetValidationKeysAsync() in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Services\Default\KeyManagement\AutomaticKeyManagerKeyStore.cs:line 105
at Duende.IdentityServer.Services.DefaultKeyMaterialService.GetValidationKeysAsync() in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Services\Default\DefaultKeyMaterialService.cs:line 112
at Duende.IdentityServer.ResponseHandling.DiscoveryResponseGenerator.CreateDiscoveryDocumentAsync(String baseUrl, String issuerUri) in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\ResponseHandling\Default\DiscoveryResponseGenerator.cs:line 109
at Duende.IdentityServer.Endpoints.DiscoveryEndpoint.ProcessAsync(HttpContext context) in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Endpoints\DiscoveryEndpoint.cs:line 65
at Duende.IdentityServer.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession userSession, IEventService events, IIssuerNameService issuerNameService, ISessionCoordinationService sessionCoordinationService) in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Hosting\IdentityServerMiddleware.cs:line 98
[15:35:12 Error] Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware
An unhandled exception has occurred while executing the request.
System.Threading.Tasks.TaskCanceledException: A task was canceled.
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternalAsync(Boolean errorsExpected, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternalAsync(Boolean errorsExpected, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenAsync(CancellationToken cancellationToken, Boolean errorsExpected)
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToArrayAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
at Duende.IdentityServer.EntityFramework.Stores.SigningKeyStore.LoadKeysAsync() in C:\ballen\work\Duende\github\IdentityServer\src\EntityFramework.Storage\Stores\SigningKeyStore.cs:line 64
at Duende.IdentityServer.Services.KeyManagement.KeyManager.GetAllKeysFromStoreAsync(Boolean cache) in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Services\Default\KeyManagement\KeyManager.cs:line 428
at Duende.IdentityServer.Services.KeyManagement.KeyManager.GetAllKeysInternalAsync() in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Services\Default\KeyManagement\KeyManager.cs:line 108
at Duende.IdentityServer.Services.KeyManagement.KeyManager.GetAllKeysAsync() in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Services\Default\KeyManagement\KeyManager.cs:line 95
at Duende.IdentityServer.Services.KeyManagement.AutomaticKeyManagerKeyStore.GetValidationKeysAsync() in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Services\Default\KeyManagement\AutomaticKeyManagerKeyStore.cs:line 105
at Duende.IdentityServer.Services.DefaultKeyMaterialService.GetValidationKeysAsync() in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Services\Default\DefaultKeyMaterialService.cs:line 112
at Duende.IdentityServer.ResponseHandling.DiscoveryResponseGenerator.CreateDiscoveryDocumentAsync(String baseUrl, String issuerUri) in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\ResponseHandling\Default\DiscoveryResponseGenerator.cs:line 109
at Duende.IdentityServer.Endpoints.DiscoveryEndpoint.ProcessAsync(HttpContext context) in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Endpoints\DiscoveryEndpoint.cs:line 65
at Duende.IdentityServer.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession userSession, IEventService events, IIssuerNameService issuerNameService, ISessionCoordinationService sessionCoordinationService) in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Hosting\IdentityServerMiddleware.cs:line 98
at Duende.IdentityServer.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession userSession, IEventService events, IIssuerNameService issuerNameService, ISessionCoordinationService sessionCoordinationService) in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Hosting\IdentityServerMiddleware.cs:line 113
at Duende.IdentityServer.Hosting.MutualTlsEndpointMiddleware.Invoke(HttpContext context, IAuthenticationSchemeProvider schemes) in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Hosting\MutualTlsEndpointMiddleware.cs:line 94
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Duende.IdentityServer.Hosting.DynamicProviders.DynamicSchemeAuthenticationMiddleware.Invoke(HttpContext context) in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Hosting\DynamicProviders\DynamicSchemes\DynamicSchemeAuthenticationMiddleware.cs:line 47
at Duende.IdentityServer.Hosting.BaseUrlMiddleware.Invoke(HttpContext context) in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Hosting\BaseUrlMiddleware.cs:line 27
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
[15:35:12 Debug] Serilog.AspNetCore.RequestLoggingMiddleware
HTTP GET /.well-known/openid-configuration responded 500 in 4680.4340 ms
.NET 7
[15:29:27 Debug] Duende.IdentityServer.Endpoints.DiscoveryEndpoint
Start discovery request
[15:29:28 Error] Microsoft.EntityFrameworkCore.Database.Connection
An error occurred using the connection to database 'Duende.EntityFramework-6.1.0' on server '(localdb)\mssqllocaldb'.
[15:29:28 Fatal] Duende.IdentityServer.Hosting.IdentityServerMiddleware
Unhandled exception: A task was canceled.
System.Threading.Tasks.TaskCanceledException: A task was canceled.
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternalAsync(Boolean errorsExpected, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternalAsync(Boolean errorsExpected, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenAsync(CancellationToken cancellationToken, Boolean errorsExpected)
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToArrayAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
at Duende.IdentityServer.EntityFramework.Stores.SigningKeyStore.LoadKeysAsync() in C:\ballen\work\Duende\github\IdentityServer\src\EntityFramework.Storage\Stores\SigningKeyStore.cs:line 64
at Duende.IdentityServer.Services.KeyManagement.KeyManager.GetAllKeysFromStoreAsync(Boolean cache) in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Services\Default\KeyManagement\KeyManager.cs:line 428
at Duende.IdentityServer.Services.KeyManagement.KeyManager.GetAllKeysInternalAsync() in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Services\Default\KeyManagement\KeyManager.cs:line 108
at Duende.IdentityServer.Services.KeyManagement.KeyManager.GetAllKeysAsync() in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Services\Default\KeyManagement\KeyManager.cs:line 95
at Duende.IdentityServer.Services.KeyManagement.AutomaticKeyManagerKeyStore.GetValidationKeysAsync() in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Services\Default\KeyManagement\AutomaticKeyManagerKeyStore.cs:line 105
at Duende.IdentityServer.Services.DefaultKeyMaterialService.GetValidationKeysAsync() in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Services\Default\DefaultKeyMaterialService.cs:line 112
at Duende.IdentityServer.ResponseHandling.DiscoveryResponseGenerator.CreateDiscoveryDocumentAsync(String baseUrl, String issuerUri) in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\ResponseHandling\Default\DiscoveryResponseGenerator.cs:line 109
at Duende.IdentityServer.Endpoints.DiscoveryEndpoint.ProcessAsync(HttpContext context) in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Endpoints\DiscoveryEndpoint.cs:line 65
at Duende.IdentityServer.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession userSession, IEventService events, IIssuerNameService issuerNameService, ISessionCoordinationService sessionCoordinationService) in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Hosting\IdentityServerMiddleware.cs:line 98
[15:29:28 Error] Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware
An unhandled exception has occurred while executing the request.
System.Threading.Tasks.TaskCanceledException: A task was canceled.
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternalAsync(Boolean errorsExpected, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternalAsync(Boolean errorsExpected, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenAsync(CancellationToken cancellationToken, Boolean errorsExpected)
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToArrayAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
at Duende.IdentityServer.EntityFramework.Stores.SigningKeyStore.LoadKeysAsync() in C:\ballen\work\Duende\github\IdentityServer\src\EntityFramework.Storage\Stores\SigningKeyStore.cs:line 64
at Duende.IdentityServer.Services.KeyManagement.KeyManager.GetAllKeysFromStoreAsync(Boolean cache) in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Services\Default\KeyManagement\KeyManager.cs:line 428
at Duende.IdentityServer.Services.KeyManagement.KeyManager.GetAllKeysInternalAsync() in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Services\Default\KeyManagement\KeyManager.cs:line 108
at Duende.IdentityServer.Services.KeyManagement.KeyManager.GetAllKeysAsync() in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Services\Default\KeyManagement\KeyManager.cs:line 95
at Duende.IdentityServer.Services.KeyManagement.AutomaticKeyManagerKeyStore.GetValidationKeysAsync() in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Services\Default\KeyManagement\AutomaticKeyManagerKeyStore.cs:line 105
at Duende.IdentityServer.Services.DefaultKeyMaterialService.GetValidationKeysAsync() in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Services\Default\DefaultKeyMaterialService.cs:line 112
at Duende.IdentityServer.ResponseHandling.DiscoveryResponseGenerator.CreateDiscoveryDocumentAsync(String baseUrl, String issuerUri) in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\ResponseHandling\Default\DiscoveryResponseGenerator.cs:line 109
at Duende.IdentityServer.Endpoints.DiscoveryEndpoint.ProcessAsync(HttpContext context) in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Endpoints\DiscoveryEndpoint.cs:line 65
at Duende.IdentityServer.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession userSession, IEventService events, IIssuerNameService issuerNameService, ISessionCoordinationService sessionCoordinationService) in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Hosting\IdentityServerMiddleware.cs:line 98
at Duende.IdentityServer.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession userSession, IEventService events, IIssuerNameService issuerNameService, ISessionCoordinationService sessionCoordinationService) in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Hosting\IdentityServerMiddleware.cs:line 113
at Duende.IdentityServer.Hosting.MutualTlsEndpointMiddleware.Invoke(HttpContext context, IAuthenticationSchemeProvider schemes) in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Hosting\MutualTlsEndpointMiddleware.cs:line 94
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Duende.IdentityServer.Hosting.DynamicProviders.DynamicSchemeAuthenticationMiddleware.Invoke(HttpContext context) in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Hosting\DynamicProviders\DynamicSchemes\DynamicSchemeAuthenticationMiddleware.cs:line 47
at Duende.IdentityServer.Hosting.BaseUrlMiddleware.Invoke(HttpContext context) in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Hosting\BaseUrlMiddleware.cs:line 27
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
[15:29:28 Debug] Serilog.AspNetCore.RequestLoggingMiddleware
HTTP GET /.well-known/openid-configuration responded 500 in 6207.1057 ms
Oh, ok... I guess the error that the Query class emitted is now gone. But the rest are still there (mainly due to being thrown?). Not sure if this really helps anything.
So then for @Stra1ghter -- we are still getting an unhandled exception in the IdentityServerMiddleware
. If we ignore this, then the host still gets this:
[15:47:56 Debug] Duende.IdentityServer.Endpoints.DiscoveryEndpoint
Start discovery request
[15:47:57 Error] Microsoft.EntityFrameworkCore.Database.Connection
An error occurred using the connection to database 'Duende.EntityFramework-6.1.0' on server '(localdb)\mssqllocaldb'.
[15:47:57 Error] Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware
An unhandled exception has occurred while executing the request.
System.Threading.Tasks.TaskCanceledException: A task was canceled.
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternalAsync(Boolean errorsExpected, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternalAsync(Boolean errorsExpected, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenAsync(CancellationToken cancellationToken, Boolean errorsExpected)
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToArrayAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
at Duende.IdentityServer.EntityFramework.Stores.SigningKeyStore.LoadKeysAsync() in C:\ballen\work\Duende\github\IdentityServer\src\EntityFramework.Storage\Stores\SigningKeyStore.cs:line 64
at Duende.IdentityServer.Services.KeyManagement.KeyManager.GetAllKeysFromStoreAsync(Boolean cache) in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Services\Default\KeyManagement\KeyManager.cs:line 428
at Duende.IdentityServer.Services.KeyManagement.KeyManager.GetAllKeysInternalAsync() in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Services\Default\KeyManagement\KeyManager.cs:line 108
at Duende.IdentityServer.Services.KeyManagement.KeyManager.GetAllKeysAsync() in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Services\Default\KeyManagement\KeyManager.cs:line 95
at Duende.IdentityServer.Services.KeyManagement.AutomaticKeyManagerKeyStore.GetValidationKeysAsync() in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Services\Default\KeyManagement\AutomaticKeyManagerKeyStore.cs:line 105
at Duende.IdentityServer.Services.DefaultKeyMaterialService.GetValidationKeysAsync() in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Services\Default\DefaultKeyMaterialService.cs:line 112
at Duende.IdentityServer.ResponseHandling.DiscoveryResponseGenerator.CreateDiscoveryDocumentAsync(String baseUrl, String issuerUri) in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\ResponseHandling\Default\DiscoveryResponseGenerator.cs:line 109
at Duende.IdentityServer.Endpoints.DiscoveryEndpoint.ProcessAsync(HttpContext context) in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Endpoints\DiscoveryEndpoint.cs:line 65
at Duende.IdentityServer.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession userSession, IEventService events, IIssuerNameService issuerNameService, ISessionCoordinationService sessionCoordinationService) in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Hosting\IdentityServerMiddleware.cs:line 98
at Duende.IdentityServer.Hosting.MutualTlsEndpointMiddleware.Invoke(HttpContext context, IAuthenticationSchemeProvider schemes) in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Hosting\MutualTlsEndpointMiddleware.cs:line 94
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Duende.IdentityServer.Hosting.DynamicProviders.DynamicSchemeAuthenticationMiddleware.Invoke(HttpContext context) in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Hosting\DynamicProviders\DynamicSchemes\DynamicSchemeAuthenticationMiddleware.cs:line 47
at Duende.IdentityServer.Hosting.BaseUrlMiddleware.Invoke(HttpContext context) in C:\ballen\work\Duende\github\IdentityServer\src\IdentityServer\Hosting\BaseUrlMiddleware.cs:line 27
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
[15:47:57 Debug] Serilog.AspNetCore.RequestLoggingMiddleware
HTTP GET /.well-known/openid-configuration responded 500 in 3809.9713 ms
So... then I'm not sure what's better? I guess it's still one less log entry. Thoughts?
@brockallen the remaining logs stem from SqlClient, right? Reading roji's answer in the issue, I thought that this is fixed with SqlClient as well, but according to #26988 this is not the case.
In case your middleware actions need to accept CancellationToken
s, then I guess we have to wait for a "real" fix in SqlClient.
Adding a filter to your middleware in general would be problematic.
Thoughts:
the remaining logs stem from SqlClient, right?
I believe yes, this line:
[15:47:57 Error] Microsoft.EntityFrameworkCore.Database.Connection
Update to EFCore 7 when you would usually do.
Yep, 6.2 is our release for targeting .NET 7.
In case your middleware actions need to accept
CancellationToken
Where? I just tried and the DI system is not happy. I was thinking we could just look at the HttpContext's RequestAborted.
Adding a filter to your middleware in general would be https://github.com/dotnet/efcore/issues/19526#issuecomment-991935231.
Why? Why not simply suppress our log entry if the exception is a TaskCanceledException and RequestAborted.IsCancellationRequested is true?
So in other words -- we still have 2 log entries to deal with. One from MS we can't do anything about, but the one from IS we can.
Currently our middleware does this:
catch (Exception ex)
{
await events.RaiseAsync(new UnhandledExceptionEvent(ex));
_logger.LogCritical(ex, "Unhandled exception: {exception}", ex.Message);
throw;
}
But I was thinking something like this:
catch (Exception ex) when (ex is not TaskCanceledException && !context.RequestAborted.IsCancellationRequested)
{
await events.RaiseAsync(new UnhandledExceptionEvent(ex));
_logger.LogCritical(ex, "Unhandled exception: {exception}", ex.Message);
throw;
}
Where? I just tried and the DI system is not happy. I was thinking we could just look at the HttpContext's RequestAborted.
Well, correct me if I'm wrong (I'm not a full time ASP.NET Core guy), but CancellationToken
s in ASP.NET Core have the purpose to stop expensive non-mutating operations. My first thought was, that you don't need this?
Example: you use your own ICancellationTokenProvider
that will end up providing HttpContext.RequestAborted
. In your EFCore ClientStore
implementation, you provide the token to the IQueryable.ToArrayAsync
, this is basically saying EFCore "throw if the token indicates a cancelation". This is beneficial for long running, expensive operations, because you could stop before doing additional work.
But in this case the query has already been issued and will be reaching SQL Server anyway and I couldn't see any other expensive operations. (Again, I don't know your codebase in-depth so I might be wrong here.)
If you would not provide a CancellationToken
to ToArrayAsync
, EFCore wouldn't care about the cancelation. (Identity Server would still work on an aborted request, but I don't think that matters as it doesn't perform batch operations?)
Why? Why not simply suppress our log entry if the exception is a TaskCanceledException and RequestAborted.IsCancellationRequested is true?
The more I think about it, the more my feelings say that you should do this. You use the tokens and don't do anything with the exception. You could in fact also catch TaskCanceledException
and log it as information. We will still see the SqlClient errors, but that is nothing you can do anything about (except not using CancellationTokens altogether).
@Stra1ghter PR has been submitted to allow flexibility here. Please have a look.
Hello,
Sorry to comment on this closed issue.
I have went down the rabbit hole of github issues related to this in the efcore repo.
Judging from the response I read from @Stra1ghter there is no way for us to avoid one of the TaskCanceledExceptions coming out of the SqlClient?
We just updated to 6.2.1 and I can see the exception handler you added in the LoggingOptions allows us to remove one of both as stated. We tried migrating to .NET 7 (Including our deps to EF Core 7) as I thought it would partially resolve but it doesn't seem like it?
@Stra1ghter:
But in this case the query has already been issued and will be reaching SQL Server anyway and I couldn't see any other expensive operations. (Again, I don't know your codebase in-depth so I might be wrong here.)
There is bunch of opportunities where the CancellationToken can cancel already issued query -> When opening connection, waiting for connection pool or even while reading data - just to name few.
In general, you should not log expected exception as critical - When you cancel a request using cancellation token, then some exception is expected.
Hello, sorry if I post in this closed thread, but I have a doubt, in case the value is:
CancellationRequested: false
is possible to ignore the exception or is the error due to some other problem? I post the stack for completeness:
System.Threading.Tasks.TaskCanceledException: A task was canceled.
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternalAsync(Boolean errorsExpected, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternalAsync(Boolean errorsExpected, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenAsync(CancellationToken cancellationToken, Boolean errorsExpected)
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToArrayAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
at Duende.IdentityServer.EntityFramework.Stores.ClientStore.FindClientByIdAsync(String clientId) in /_/src/EntityFramework.Storage/Stores/ClientStore.cs:line 87
at Duende.IdentityServer.Stores.ValidatingClientStore`1.FindClientByIdAsync(String clientId) in /_/src/IdentityServer/Stores/ValidatingClientStore.cs:line 76
at Duende.IdentityServer.Stores.IClientStoreExtensions.FindEnabledClientByIdAsync(IClientStore store, String clientId) in /_/src/IdentityServer/Extensions/IClientStoreExtensions.cs:line 27
at Duende.IdentityServer.Validation.AuthorizeRequestValidator.LoadClientAsync(ValidatedAuthorizeRequest request) in /_/src/IdentityServer/Validation/Default/AuthorizeRequestValidator.cs:line 228
at Duende.IdentityServer.Validation.AuthorizeRequestValidator.ValidateAsync(NameValueCollection parameters, ClaimsPrincipal subject) in /_/src/IdentityServer/Validation/Default/AuthorizeRequestValidator.cs:line 146
at Duende.IdentityServer.Services.OidcReturnUrlParser.ParseAsync(String returnUrl) in /_/src/IdentityServer/Services/Default/OidcReturnUrlParser.cs:line 67
at Duende.IdentityServer.Services.ReturnUrlParser.ParseAsync(String returnUrl) in /_/src/IdentityServer/Services/Default/ReturnUrlParser.cs:line 46
at Duende.IdentityServer.Services.DefaultIdentityServerInteractionService.GetAuthorizationContextAsync(String returnUrl) in /_/src/IdentityServer/Services/Default/DefaultIdentityServerInteractionService.cs:line 68
is possible to ignore the exception or is the error due to some other problem?
You can wrap our middleware in your own try/catch and control that any way you want.
Hi, maybe my question wasn't very clear, since the task cancellation is not requested, this type of exception is still a false positive and therefore I don't have to worry or is it a problem with my application/database and I have to investigate what? Thank you
Oh I see -- so you're getting this exception but the request was not cancelled by the caller? In that case, I'm not sure -- do you have more details of the exception?
Here is the entire exception log:
{
"@t": "2023-03-23T11:59:42.0082567Z",
"@mt": "An unhandled exception has occurred while executing the request.",
"@l": "Error",
"@x": "System.Threading.Tasks.TaskCanceledException: A task was canceled.\r\n at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternalAsync(Boolean errorsExpected, CancellationToken cancellationToken)\r\n at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternalAsync(Boolean errorsExpected, CancellationToken cancellationToken)\r\n at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenAsync(CancellationToken cancellationToken, Boolean errorsExpected)\r\n at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)\r\n at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken)\r\n at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)\r\n at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()\r\n at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)\r\n at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)\r\n at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToArrayAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)\r\n at Duende.IdentityServer.EntityFramework.Stores.ClientStore.FindClientByIdAsync(String clientId) in /_/src/EntityFramework.Storage/Stores/ClientStore.cs:line 87\r\n at Duende.IdentityServer.Stores.ValidatingClientStore`1.FindClientByIdAsync(String clientId) in /_/src/IdentityServer/Stores/ValidatingClientStore.cs:line 76\r\n at Duende.IdentityServer.Stores.IClientStoreExtensions.FindEnabledClientByIdAsync(IClientStore store, String clientId) in /_/src/IdentityServer/Extensions/IClientStoreExtensions.cs:line 27\r\n at Duende.IdentityServer.Validation.AuthorizeRequestValidator.LoadClientAsync(ValidatedAuthorizeRequest request) in /_/src/IdentityServer/Validation/Default/AuthorizeRequestValidator.cs:line 228\r\n at Duende.IdentityServer.Validation.AuthorizeRequestValidator.ValidateAsync(NameValueCollection parameters, ClaimsPrincipal subject) in /_/src/IdentityServer/Validation/Default/AuthorizeRequestValidator.cs:line 146\r\n at Duende.IdentityServer.Endpoints.AuthorizeEndpointBase.ProcessAuthorizeRequestAsync(NameValueCollection parameters, ClaimsPrincipal user, Boolean checkConsentResponse) in /_/src/IdentityServer/Endpoints/AuthorizeEndpointBase.cs:line 153\r\n at Duende.IdentityServer.Endpoints.AuthorizeCallbackEndpoint.ProcessAsync(HttpContext context) in /_/src/IdentityServer/Endpoints/AuthorizeCallbackEndpoint.cs:line 55\r\n at Duende.IdentityServer.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IdentityServerOptions options, IEndpointRouter router, IUserSession userSession, IEventService events, IIssuerNameService issuerNameService, ISessionCoordinationService sessionCoordinationService) in /_/src/IdentityServer/Hosting/IdentityServerMiddleware.cs:line 121\r\n at Duende.IdentityServer.Hosting.MutualTlsEndpointMiddleware.Invoke(HttpContext context, IAuthenticationSchemeProvider schemes) in /_/src/IdentityServer/Hosting/MutualTlsEndpointMiddleware.cs:line 95\r\n at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)\r\n at Duende.IdentityServer.Hosting.DynamicProviders.DynamicSchemeAuthenticationMiddleware.Invoke(HttpContext context) in /_/src/IdentityServer/Hosting/DynamicProviders/DynamicSchemes/DynamicSchemeAuthenticationMiddleware.cs:line 48\r\n at Duende.IdentityServer.Hosting.BaseUrlMiddleware.Invoke(HttpContext context) in /_/src/IdentityServer/Hosting/BaseUrlMiddleware.cs:line 28\r\n at UI.Middlewares.SamlProxyMiddleware.InvokeAsync(HttpContext context) in C:\\AG1_v2.165.0\\_work\\711\\s\\src\\Web\\UI\\Middlewares\\SamlProxyMiddleware.cs:line 42\r\n at NWebsec.AspNetCore.Middleware.Middleware.MiddlewareBase.Invoke(HttpContext context)\r\n at NWebsec.AspNetCore.Middleware.Middleware.MiddlewareBase.Invoke(HttpContext context)\r\n at UI.Middlewares.NotFoundMiddleware.InvokeAsync(HttpContext context) in C:\\AG1_v2.165.0\\_work\\711\\s\\src\\Web\\UI\\Middlewares\\NotFoundMiddleware.cs:line 22\r\n at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.<Invoke>g__Awaited|8_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task)",
"EventId": {
"Id": 1,
"Name": "UnhandledException"
},
"SourceContext": "Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware",
"RequestId": "80000a0c-0001-dd00-b63f-84710c7967bb",
"RequestPath": "/connect/authorize/callback",
"ExceptionDetail": {
"Type": "System.Threading.Tasks.TaskCanceledException",
"HResult": -2146233029,
"Message": "A task was canceled.",
"Source": "System.Private.CoreLib",
"TargetSite": "Void ThrowForNonSuccess(System.Threading.Tasks.Task)",
"CancellationToken": "CancellationRequested: false",
"Task": {
"Id": 6,
"Status": "Canceled",
"CreationOptions": "None"
}
}
}
Well... all that shows is that the cancellation token that was passed into the EF layer was triggered. Unless you did anything special, then it's ASP.NET doing it due to some reason. We did make the filter (UnhandledExceptionLoggingFilter) we use extensible so you can look closer at the exception and decide if you want to ignore it or not:
https://docs.duendesoftware.com/identityserver/v6/reference/options/#logging
Thanks, I'll try to investigate and understand the problem.
Which version of Duende IdentityServer are you using? 6.1.5 Which version of .NET are you using? net6.0
Describe the bug
When a user cancels a browser request that is handled by
IdentityServerMiddleware
theTaskCanceledException
is logged as a critical log. We see the errors in different stack traces, but it is always a task that finally queries some store via EF Core.To Reproduce
I couldn't absolutely reproduce the behaviour, but it seems to be known. This usually always happens when you accept a
CancellationToken
in your actions, e.g. for long running operations, but don't handle the cancellation of the task.Please note that it's now possible in EF Core to distinguish between cancellation and failure.
Expected behavior
Handle user caused task cancellations (e.g. clicking stop or refresh in the browser) by a custom filter, that could log this as information or debug.
Another solution would be to simply stop accepting and passing
CancellationToken
on IdentityServer's actions. I don't think IdentityServer has long running tasks that would benefit from knowing about the cancellation of a task, but I might be wrong here.Log output/exception with stacktrace
Stack trace is trimmed due to the fact that it exceeds maximum number of characters.