Skip to content

Endpoint routing failures are cached #43693

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

Closed
1 task done
davidfowl opened this issue Sep 1, 2022 · 4 comments · Fixed by #43729
Closed
1 task done

Endpoint routing failures are cached #43693

davidfowl opened this issue Sep 1, 2022 · 4 comments · Fixed by #43729
Assignees
Labels
bug This issue describes a behavior which is not expected - a bug. feature-routing old-area-web-frameworks-do-not-use *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels
Milestone

Comments

@davidfowl
Copy link
Member

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When an EndpointDataSources throws an exception while building endpoints the exception is observed once on the first request and subsequent requests end up 404-ing.

Expected Behavior

The exception should be thrown every time.

Steps To Reproduce

var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

app.MapGet("/", () => "Hello World!"u8);

app.Run();

Exceptions (if any)

An exception and then a 404 on the second request.

.NET Version

7.0.100-rc.2.22426.5

Anything else?

No response

@javiercn javiercn added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates feature-routing labels Sep 1, 2022
@TanayParikh
Copy link
Contributor

TanayParikh commented Sep 1, 2022

Hey @davidfowl where does the exception come from in this case; is it the UTF8 string?

@danroth27
Copy link
Member

System.InvalidProgramException: Common Language Runtime detected an invalid program.
at System.Reflection.Emit.DynamicMethod.CreateDelegate(Type delegateType, Object target)
at System.Linq.Expressions.Compiler.LambdaCompiler.Compile(LambdaExpression lambda)
at System.Linq.Expressions.Expression1.Compile() at Microsoft.AspNetCore.Http.RequestDelegateFactory.CreateTargetableRequestDelegate(MethodInfo methodInfo, Expression targetExpression, FactoryContext factoryContext, Expression1 targetFactory)
at Microsoft.AspNetCore.Http.RequestDelegateFactory.Create(Delegate handler, RequestDelegateFactoryOptions options)
at Microsoft.AspNetCore.Routing.RouteEndpointDataSource.CreateRouteEndpointBuilder(RouteEntry entry, RoutePattern groupPrefix, IReadOnlyList1 groupConventions, IReadOnlyList1 groupFinallyConventions)
at Microsoft.AspNetCore.Routing.RouteEndpointDataSource.get_Endpoints()
at Microsoft.AspNetCore.Routing.CompositeEndpointDataSource.CreateEndpointsUnsynchronized()
at Microsoft.AspNetCore.Routing.CompositeEndpointDataSource.EnsureEndpointsInitialized()
at Microsoft.AspNetCore.Routing.DataSourceDependentCache1.Initialize() at System.Threading.LazyInitializer.EnsureInitializedCore[T](T& target, Boolean& initialized, Object& syncLock, Func1 valueFactory)
at Microsoft.AspNetCore.Routing.Matching.DataSourceDependentMatcher..ctor(EndpointDataSource dataSource, Lifetime lifetime, Func1 matcherBuilderFactory) at Microsoft.AspNetCore.Routing.Matching.DfaMatcherFactory.CreateMatcher(EndpointDataSource dataSource) at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.InitializeCoreAsync() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.<Invoke>g__AwaitMatcher|8_0(EndpointRoutingMiddleware middleware, HttpContext httpContext, Task1 matcherTask)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)

@davidfowl
Copy link
Member Author

@halter73 can you take a look at this one? It’s from the composite data source changes

@davidfowl davidfowl added old-area-web-frameworks-do-not-use *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels and removed area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels Sep 1, 2022
@halter73
Copy link
Member

halter73 commented Sep 1, 2022

Yeah. I'll definitely look into this tomorrow.

@halter73 halter73 self-assigned this Sep 3, 2022
@halter73 halter73 modified the milestones: .NET 8 Planning, 7.0-rc2 Sep 3, 2022
@halter73 halter73 linked a pull request Sep 6, 2022 that will close this issue
10 tasks
@halter73 halter73 closed this as completed Sep 6, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Oct 7, 2022
@danroth27 danroth27 added the bug This issue describes a behavior which is not expected - a bug. label Oct 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue describes a behavior which is not expected - a bug. feature-routing old-area-web-frameworks-do-not-use *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants