Is there an existing issue for this?
Description
When a client-side exception occurs in Blazor WebAssembly often a StackOverflow exception in the browser occurs with more than 1000 log messages.
Analyze why this occurred:
In UserExceptionInformer.cs the exception is logged:
protected virtual void LogException(UserExceptionInformerContext context)
{
if (context.Exception is AbpRemoteCallException && OperatingSystem.IsBrowser())
{
return;
}
Logger.LogException(context.Exception);
}
This uses a custom Logger in AbpLoggerExtensions.cs
Analyse with ChatGPT results in:
Yes — the recursion is almost certainly coming from this exact line:
ex.Log(logger);
inside:
foreach (var ex in loggingExceptions)
{
ex.Log(logger);
}
because IExceptionWithSelfLogging.Log() implementations in ABP frequently call logging again.
The recursion chain becomes:
Logger.LogException(exception)
-> LogSelfLogging()
-> exception.Log(logger)
-> logger.LogException(exception)
-> LogSelfLogging()
-> exception.Log(logger)
That is a textbook infinite recursion leading to StackOverflowException.
The important thing is:
the recursion is NOT in ILogger
it is in ABP's extension pipeline
The second likely issue is this block:
JsonSerializer.Serialize(value)
inside:
FormatDataValue()
Blazor WASM exceptions often contain:
JS interop handles
component references
async state machines
circular graphs
Serialization can recurse indefinitely there too.
Solution:
Simplest avoiding LogException, but this will not fix the rootcause:
protected virtual void LogException(UserExceptionInformerContext context)
{
if (context.Exception is AbpRemoteCallException && OperatingSystem.IsBrowser())
{
return;
}
Console.WriteLine($"{context.Exception.GetType().FullName}: {context.Exception.Message}");
if (context.Exception.InnerException is not null)
{
Console.WriteLine($"InnerException: {context.Exception.InnerException}");
}
Reproduction Steps
No response
Expected behavior
No response
Actual behavior
No response
Regression?
No response
Known Workarounds
No response
Version
10.4
User Interface
Blazor
Database Provider
EF Core (Default)
Tiered or separate authentication server
Tiered
Operation System
Windows (Default)
Other information
No response
Is there an existing issue for this?
Description
When a client-side exception occurs in Blazor WebAssembly often a StackOverflow exception in the browser occurs with more than 1000 log messages.
Analyze why this occurred:
In UserExceptionInformer.cs the exception is logged:
This uses a custom Logger in
AbpLoggerExtensions.csAnalyse with ChatGPT results in:
Yes — the recursion is almost certainly coming from this exact line:
ex.Log(logger);
inside:
foreach (var ex in loggingExceptions)
{
ex.Log(logger);
}
because IExceptionWithSelfLogging.Log() implementations in ABP frequently call logging again.
The recursion chain becomes:
Logger.LogException(exception)
-> LogSelfLogging()
-> exception.Log(logger)
-> logger.LogException(exception)
-> LogSelfLogging()
-> exception.Log(logger)
That is a textbook infinite recursion leading to StackOverflowException.
The important thing is:
the recursion is NOT in ILogger
it is in ABP's extension pipeline
The second likely issue is this block:
JsonSerializer.Serialize(value)
inside:
FormatDataValue()
Blazor WASM exceptions often contain:
JS interop handles
component references
async state machines
circular graphs
Serialization can recurse indefinitely there too.
Solution:
Simplest avoiding LogException, but this will not fix the rootcause:
Reproduction Steps
No response
Expected behavior
No response
Actual behavior
No response
Regression?
No response
Known Workarounds
No response
Version
10.4
User Interface
Blazor
Database Provider
EF Core (Default)
Tiered or separate authentication server
Tiered
Operation System
Windows (Default)
Other information
No response