ivanpaulovich / FluentMediator

:twisted_rightwards_arrows: FluentMediator is an unobtrusive library that allows developers to build custom pipelines for Commands, Queries and Events.
http://paulovich.net/FluentMediator/
Apache License 2.0
192 stars 17 forks source link

Issue using blazor virtualize component with FluentMediator #51

Open leandrofagundes opened 2 years ago

leandrofagundes commented 2 years ago

Hi guys,

I'm using FluentMediator in two of my projects. Last days I found an issue in my app where my requests get an OperationCancelledException. After a few hours trying to resolve, I found it on my Windows Event Viewers. It's looks like the FluentMediator crashing between my controller and my use case class. Can you guys check it out?

_at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context) fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1] An unhandled exception has occurred while executing the request. System.OperationCanceledException: The operation was canceled. at System.Threading.CancellationToken.ThrowOperationCanceledException() at FluentMediator.Pipelines.CancellablePipelineAsync.Pipeline.PublishAsync(GetService getService, Object request, CancellationToken cancellationToken) at FluentMediator.Mediator.PublishAsync(Object request, CancellationToken cancellationToken, String pipelineName) at LetzIt.Admin.WebAPI.UseCases.V1.Users.Get.UsersController.Get(RequestDTO request, CancellationToken cancellationToken) in C:\Users\Leandro\source\repos\letzit\admin-webservice\src\Admin.WebAPI\UseCases\V1\Users\Get\UsersController.cs:line 43 at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask1 actionResultValueTask) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.gAwaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.gAwaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|60(Endpoint endpoint, Task requestTask, ILogger logger) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext) at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider) at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)`

leandrofagundes commented 2 years ago

Maybe I'm wrong, but I want to check the cancellation token in my use case.

The class FluentMediator/src/FluentMediator/Pipelines/CancellablePipelineAsync/Pipeline.cs / is checking if the token is cancelled and throwing an exception. Probably here is my problem.