elsa-workflows / elsa-workflows/elsa-core

HttpEndpointMiddleware - When it fails issue

Open
#2,854 4 comments 0 reactions 0 assignees View on GitHub
bug triaged
Dominant language
C#
Stars
7.9k
Forks
1.5k
Avg merge
15h 22m
Merged PRs (30d)
114

Description

This is the first time this one has popped up in a year of using Elsa 2...

Note - Im stuck on 2.3 until I can test the latest preview builds, but just checking this one won't cause any other issues down the line. The following error began from a request to a SignalR hub (a few hundred will be trying to get back in contact) to reconnect to the site. Restarting fixed the error below.

`HttpEndpointMiddleware` ->

The following exception caused the site to appear offline as no further requests could complete. The switch from an In memory to a provider with persistence will have a slightly different outcome when I finally get to upgrade but some other things come to mind.

- It would be effective if the middleware was configurable so that it can only act on certain routes eg `/elsa-endpoint/**/*`. It creates extra work that the majority of requests don't need. Switching to minimal APIs might also be an interesting solution as well (but a different package), but can minimal endpoints (minimal apis .NET 6) get added/modified during the publishing of a workflow ... I'm less knowledgeable on that?.
- Failure shouldn't throw on the request - might be debatable.
- What could be done to heal itself short of restarting

```
System.NullReferenceException: Object reference not set to an instance of an object.
at lambda_method531644(Closure , Bookmark )
at Elsa.Persistence.Specifications.Specification`1.IsSatisfiedBy(T entity)
at Elsa.Persistence.Specifications.OrSpecification`1.IsSatisfiedBy(T entity)
at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Elsa.Persistence.InMemory.InMemoryStore`1.FindManyAsync(ISpecification`1 specification, IOrderBy`1 orderBy, IPaging paging, CancellationToken cancellationToken)
at Elsa.Services.Bookmarks.BookmarkFinder.FindBookmarksAsync(String activityType, IEnumerable`1 bookmarks, String correlationId, String tenantId, CancellationToken cancellationToken)
at Elsa.Services.Workflows.WorkflowLaunchpad.CollectResumableAndStartableWorkflowsAsync(WorkflowsQuery query, CancellationToken cancellationToken)
at Elsa.Services.Workflows.WorkflowLaunchpad.FindWorkflowsAsync(WorkflowsQuery query, CancellationToken cancellationToken)
at Open.Linq.AsyncExtensions.Extensions.ToList[TSource](Task`1 source)
at Elsa.Activities.Http.Middleware.HttpEndpointMiddleware.InvokeAsync(HttpContext httpContext, IOptions`1 options, IWorkflowLaunchpad workflowLaunchpad, IWorkflowInstanceStore workflowInstanceStore, IWorkflowRegistry workflowRegistry, IWorkflowBlueprintReflector workflowBlueprintReflector, IHttpEndpointAuthorizationHandler authorizationHandler, IEnumerable`1 contentParsers)
at Microsoft.AspNetCore.Authorization.Policy.AuthorizationMiddlewareResultHandler.HandleAsync(RequestDelegate next, HttpContext context, AuthorizationPolicy policy, PolicyAuthorizationResult authorizeResult)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.HandleException(HttpContext context, ExceptionDispatchInfo edi)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)
at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContextOfT`1.ProcessRequestAsync()
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.