Skip to content

Avoid stack overflow when logging exceptions in Blazor WebAssembly#25464

Merged
EngincanV merged 1 commit into
rel-10.4from
maliming/fix-blazor-wasm-stackoverflow-logging
May 26, 2026
Merged

Avoid stack overflow when logging exceptions in Blazor WebAssembly#25464
EngincanV merged 1 commit into
rel-10.4from
maliming/fix-blazor-wasm-stackoverflow-logging

Conversation

@maliming

Copy link
Copy Markdown
Member

Fixes #25463

AbpExceptionHandlingLoggerProvider is registered in the MEL pipeline by the WebAssembly module so that any Error/Critical log with an exception is forwarded to IUserExceptionInformer.Inform for UI display. The default UserExceptionInformer.LogException then writes the same exception back through ILogger<UserExceptionInformer>, which re-enters the same provider and recurses until the browser stack overflows.

Filter out the UserExceptionInformer category from AbpExceptionHandlingLoggerProvider at registration time so the informer's own log writes do not loop back into the provider. Other logger providers (console, Serilog, etc.) still receive these log records.

Filter out UserExceptionInformer category from AbpExceptionHandlingLoggerProvider so logs written by the informer do not re-enter the same provider, which previously caused infinite recursion and a browser stack overflow.

Fixes #25463
Copilot AI review requested due to automatic review settings May 22, 2026 09:49
@maliming maliming added this to the 10.4-patch milestone May 22, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a Blazor WebAssembly logging recursion where exceptions forwarded to IUserExceptionInformer.Inform are re-logged by UserExceptionInformer, re-entering AbpExceptionHandlingLoggerProvider until the browser stack overflows.

Changes:

  • Filters out the UserExceptionInformer log category for AbpExceptionHandlingLoggerProvider during WebAssembly module logging setup to prevent re-entrancy loops.
  • Adds a regression test ensuring an informer writing to the same logging pipeline does not cause recursion.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
framework/test/Volo.Abp.AspNetCore.Components.Web.Theming.Tests/Volo/Abp/AspNetCore/Components/Web/ExceptionHandling/AbpExceptionHandlingLogger_Tests.cs Adds a regression test that reproduces the recursion scenario and asserts it’s prevented by category filtering.
framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpAspNetCoreComponentsWebAssemblyModule.cs Applies a provider-specific category filter to exclude UserExceptionInformer logs from the exception-handling provider, preventing infinite recursion.

@maliming maliming requested a review from EngincanV May 22, 2026 09:54
@codecov

codecov Bot commented May 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.42%. Comparing base (9ddc151) to head (865c5bc).
⚠️ Report is 16 commits behind head on rel-10.4.

Files with missing lines Patch % Lines
...sembly/AbpAspNetCoreComponentsWebAssemblyModule.cs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           rel-10.4   #25464      +/-   ##
============================================
+ Coverage     49.39%   49.42%   +0.02%     
============================================
  Files          3670     3670              
  Lines        123594   123599       +5     
  Branches       9452     9453       +1     
============================================
+ Hits          61055    61084      +29     
+ Misses        60705    60676      -29     
- Partials       1834     1839       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@EngincanV EngincanV merged commit 4265df0 into rel-10.4 May 26, 2026
4 of 5 checks passed
@EngincanV EngincanV deleted the maliming/fix-blazor-wasm-stackoverflow-logging branch May 26, 2026 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants