Skip to content
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

Too many scopes created #1634

Closed
sebastienros opened this issue Mar 27, 2018 · 4 comments
Closed

Too many scopes created #1634

sebastienros opened this issue Mar 27, 2018 · 4 comments
Labels
Milestone

Comments

@sebastienros
Copy link
Member

We are going in the ModularTenantContainerMiddleware and creating a service scope even for serving a static file.

@sebastienros sebastienros added this to the rc milestone Mar 27, 2018
@sebastienros
Copy link
Member Author

After all I am not really sure that's an issue. I assume the static file middleware also requires it?

@sebastienros sebastienros modified the milestones: rc, 1.0 Aug 11, 2019
@sebastienros sebastienros modified the milestones: 1.0, 1.1 Apr 2, 2020
@agriffard
Copy link
Member

/cc @jtkech

@jtkech
Copy link
Member

jtkech commented Dec 27, 2020

So here we would need to register IModuleStaticFileProvider at the builder.ApplicationServices level, just tried it works. And enlist the related middleware at the app level, not through the tenant pipeline that will be executed in a scope context, just tried it works. The only problem is that it is no more tenant aware, make sense for shared static files but we commonly generate url including the tenant url prefix, so we would need to remove this tenant prefix.

Note: There are other custom static file providers that should be tenant aware and whose urls should contain the prefix.

Another solution is to run a middleware after the app level ones but before our tenant and router middlewares, just to update the request PathBase according to the tenant (currently updated in the tenant router middleware), then use the static file middleware based on our IModuleStaticFileProvider, and finally our tenant and router middlewares.

Yes it is doable, let me know if it is worth doing it

That said, creating a new scope (on an already activated shell) is fast and not expensive if you don't resolve any services, and our ModuleEmbeddedStaticFileProvider and ModuleProjectStaticFileProvider are stateless and don't resolve any services.

@Piedone
Copy link
Member

Piedone commented Apr 24, 2024

Yes, it's necessary to create scopes even for static file requests. This is required to do anything else in the request apart from serving the file, including collecting telemetry or authorization.

@Piedone Piedone closed this as not planned Won't fix, can't repro, duplicate, stale Apr 24, 2024
@MikeAlhayek MikeAlhayek modified the milestones: 2.x, 2.0 Sep 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants