Skip to content

Blocking against static files (css/js) #14

@timgabrhel

Description

@timgabrhel

I am just getting started using the middleware, and I'm coming across some blocking notes against our html/css files. I am not sure how this should be handled. Any direction?

ASP.NET Core 3.1

info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/2.0 GET https://localhost:44307/login  
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
      Executing endpoint 'WebMvc.Areas.Account.Controllers.AuthController.Login (WebMvc)'
info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[3]
      Route matched with {area = "Account", action = "Login", controller = "Auth"}. Executing controller action with signature Microsoft.AspNetCore.Mvc.IActionResult Login(System.String, System.String) on controller WebMvc.Areas.Account.Controllers.AuthController (WebMvc).
info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[1]
      Executing action method WebMvc.Areas.Account.Controllers.AuthController.Login (WebMvc) - Validation state: Valid
info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[2]
      Executed action method WebMvc.Areas.Account.Controllers.AuthController.Login (WebMvc), returned result Microsoft.AspNetCore.Mvc.ViewResult in 0.0505ms.
info: Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor[1]
      Executing ViewResult, running view Login.
info: Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor[4]
      Executed ViewResult - view Login executed in 5.4982ms.
info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[2]
      Executed action WebMvc.Areas.Account.Controllers.AuthController.Login (WebMvc) in 9.9739ms
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
      Executed endpoint 'WebMvc.Areas.Account.Controllers.AuthController.Login (WebMvc)'
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/2.0 GET https://localhost:44307/css/Site.css?v=637231648404436533  
warn: Ben.Diagnostics.BlockingMonitor[6]
      Blocking method has been invoked and blocked, this can lead to threadpool starvation.
         at System.IO.FileStream.ReadAsyncInternal(Memory`1 destination, CancellationToken cancellationToken, Int32& synchronousResult)
         at System.IO.FileStream.ReadAsyncTask(Byte[] array, Int32 offset, Int32 count, CancellationToken cancellationToken)
         at System.IO.FileStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
         at Microsoft.AspNetCore.Http.StreamCopyOperationInternal.CopyToAsync(Stream source, Stream destination, Nullable`1 count, Int32 bufferSize, CancellationToken cancel)
         at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.AsyncStateMachineBox`1.ExecutionContextCallback(Object s)
         at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
         at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.AsyncStateMachineBox`1.MoveNext(Thread threadPoolThread)
         at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.AsyncStateMachineBox`1.MoveNext()
         at System.Runtime.CompilerServices.TaskAwaiter.<>c.<OutputWaitEtwEvents>b__12_0(Action innerContinuation, Task innerTask)
         at System.Threading.Tasks.AwaitTaskContinuation.System.Threading.IThreadPoolWorkItem.Execute()
         at System.Threading.ThreadPoolWorkQueue.Dispatch()
      
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[2]
      Sending file. Request path: '/css/Site.css'. Physical path: 'C:\dev\WebMvc\wwwroot\css\Site.css'
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished in 47.1026ms 200 text/css
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/2.0 GET https://localhost:44307/js/site.js?v=637231648404439536  
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[2]
      Sending file. Request path: '/js/site.js'. Physical path: 'C:\dev\wagt\WebMvc\wwwroot\js\site.js'
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished in 72.4794ms 200 application/javascript
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished in 306.2087ms 200 text/html; charset=utf-8
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/2.0 POST https://localhost:44307/profiler/results application/json 835
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished in 233.0392ms 200 application/json

Here's the Configure method.

        public void Configure(IApplicationBuilder app)
        {
            app.UseBlockingDetection();

            if (Environment.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
                app.UseExceptionHandler("/error");
                app.UseStatusCodePagesWithRedirects("/error/{0}");
            }

            app.UseHttpsRedirection();

            app.UseSession();

            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();

            app.UseMiniProfiler();

            // app custom
            app.UseMaintenanceMiddleware();
            app.UseLegacyRedirectMiddleware();
            app.UseRequestRefreshClaimsMiddleware();

            app.UseEndpoints(delegate (IEndpointRouteBuilder endpoints)
            {
                endpoints.MapControllerRoute("areaRoute", "{area:exists}/{controller=Dashboard}/{action=Index}/{id?}");
                endpoints.MapDefaultControllerRoute();
            });
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions