Getting 'JsPoolExhaustedException' exception when using ReactJS.Net library - Recommended settings question

64 Views Asked by At

We are using ReactJS.Net (https://github.com/reactjs/react.net) as part of our .Net 6 web application that is hosted on an Azure App Service.

Screenshot of ReactJS.Net NuGet package

We have the following configuration within our Startup.cs file:

app.UseReact(config =>
{
    config
        .SetLoadBabel(false)
        .AddScriptWithoutTransform("~/assets/js/kitchensink.server.bundle.js")
        .SetUseDebugReact(StaticConfig.GetValue("CLIENT:React.DebugOutput", false))
        .DisableServerSideRendering()
        .SetMaxEngines(50); //Increased from the default of 25
});

However, under an increased load, we are getting the following errors and the site is going down:

JSPool.Exceptions.JsPoolExhaustedException:
   at JSPool.JsPool`2.GetEngine (JSPool, Version=4.0.0.0, Culture=neutral, PublicKeyToken=2fc7775f73072640)
   at React.JavaScriptEngineFactory.GetEngine (React.Core, Version=5.2.0.0, Culture=neutral, PublicKeyToken=9aed67b161f7db78)
   at System.Lazy`1.ViaFactory (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Lazy`1.ExecutionAndPublication (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Lazy`1.CreateValue (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at React.ReactEnvironment.get_Engine (React.Core, Version=5.2.0.0, Culture=neutral, PublicKeyToken=9aed67b161f7db78)
   at React.ReactEnvironment.EnsureUserScriptsLoaded (React.Core, Version=5.2.0.0, Culture=neutral, PublicKeyToken=9aed67b161f7db78)
   at React.ReactEnvironment.CreateComponent (React.Core, Version=5.2.0.0, Culture=neutral, PublicKeyToken=9aed67b161f7db78)
   at CLIENT.Cms.App.Extensions.HtmlHelperExtensions.ReactForOptimizely (CLIENT.Cms.App, Version=1.9.16.106, Culture=neutral, PublicKeyToken=null: D:\a\1\s\src\BackEnd\CLIENT.Cms.App\Extensions\HtmlHelperExtensions.cs:51)
   at AspNetCoreGeneratedDocument.Views_Shared_Components_Header_Default+<ExecuteAsync>d__0.MoveNext (CLIENT.Cms.App, Version=1.9.16.106, Culture=neutral, PublicKeyToken=null: D:\a\1\s\src\BackEnd\CLIENT.Cms.App\Views\Shared\Components\Header\Default.cshtml:3)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=XXX)

From Intellisense, it appears that we can configure the following (along with their default values) in the Startup.cs configuration:

  • MaxEngines (25)
  • MaxUsagesPerEngine (100)
  • ReuseJavaScriptEngines
  • StartEngines (10)

Q1. Are there any guidelines for what these could/should be set to in a Production environment with a moderate amount of traffic? (i.e. A few thousand users per day - each browsing a small number of pages <--- I appreciate that this isn't very scientific and can get exact stats if it would help)

Q2. Is there further documentation somewhere about exactly what these settings do and the possible implications of changing them?

Q3. Is there something else we may be missing?

0

There are 0 best solutions below