Martin Shishkov Martin Shishkov - 1 month ago 18
React JSX Question

reactjs.net - 'potential stack overflow detected' error

Since I've decided to switch to server-side rendering from client-side react, I began to create my components and use them in the app.

However I came across this error:

Unknown error (RangeError); potential stack overflow detected

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Microsoft.ClearScript.ScriptEngineException: Unknown error (RangeError); potential stack overflow detected


And this is a part from the
stack-trace


[ScriptEngineException: Unknown error (RangeError); potential stack overflow detected]
V8Exception.ThrowScriptEngineException(V8Exception* ) +169
Microsoft.ClearScript.V8.V8ContextProxyImpl.Execute(String gcDocumentName, String gcCode, Boolean evaluate, Boolean discard) +462
Microsoft.ClearScript.V8.<>c__DisplayClass1b.<Execute>b__19() +197
Microsoft.ClearScript.ScriptEngine.ScriptInvoke(Func`1 func) +70
Microsoft.ClearScript.V8.V8ScriptEngine.BaseScriptInvoke(Func`1 func) +49
Microsoft.ClearScript.V8.<>c__DisplayClass25`1.<ScriptInvoke>b__24() +45
Microsoft.ClearScript.V8.?A0x792c8756.LockCallback(Void* pvArg) +9
Microsoft.ClearScript.V8.V8ContextProxyImpl.InvokeWithLock(Action gcAction) +176
Microsoft.ClearScript.V8.V8ScriptEngine.ScriptInvoke(Func`1 func) +118
Microsoft.ClearScript.V8.V8ScriptEngine.Execute(String documentName, String code, Boolean evaluate, Boolean discard) +118
JavaScriptEngineSwitcher.V8.V8JsEngine.InnerEvaluate(String expression) +89


So I don't know what causes this error but I think it is some code that goes in a loop or something similar. Furthermore if I refresh the page this error goes away and if I continue to refresh intensively it shows up again which is very frustrating.

Answer

This is a known issue, see https://github.com/reactjs/React.NET/issues/190

The work around is to not use V8 to do the render ie:

app.UseReact(config =>
        {
            config
                // ..other configuration settings
                .SetAllowMsieEngine(true);
        });