From 804cd0ff1070ec3a7a2794838934b1ee2de42102 Mon Sep 17 00:00:00 2001 From: Alex Sohn Date: Tue, 9 Sep 2025 14:00:27 -0400 Subject: [PATCH 1/5] fix: Ensure profiling disabled in Blazor WASM We don't support profiling in Blazor WebAssembly. If a user has Blazor WebAssembly application with Sentry Profiling, we will disable profiling and log to the console that profiling is not available, and that we disabled profiling. --- ...entry.AspNetCore.Blazor.WebAssembly.csproj | 1 + .../WebAssemblyHostBuilderExtensions.cs | 20 +++++++++++++++++++ src/Sentry/Sentry.csproj | 3 ++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/Sentry.AspNetCore.Blazor.WebAssembly/Sentry.AspNetCore.Blazor.WebAssembly.csproj b/src/Sentry.AspNetCore.Blazor.WebAssembly/Sentry.AspNetCore.Blazor.WebAssembly.csproj index 4ff5701fa0..263ab88be4 100644 --- a/src/Sentry.AspNetCore.Blazor.WebAssembly/Sentry.AspNetCore.Blazor.WebAssembly.csproj +++ b/src/Sentry.AspNetCore.Blazor.WebAssembly/Sentry.AspNetCore.Blazor.WebAssembly.csproj @@ -7,6 +7,7 @@ + diff --git a/src/Sentry.AspNetCore.Blazor.WebAssembly/WebAssemblyHostBuilderExtensions.cs b/src/Sentry.AspNetCore.Blazor.WebAssembly/WebAssemblyHostBuilderExtensions.cs index ca208e0280..8d54efcf47 100644 --- a/src/Sentry.AspNetCore.Blazor.WebAssembly/WebAssemblyHostBuilderExtensions.cs +++ b/src/Sentry.AspNetCore.Blazor.WebAssembly/WebAssemblyHostBuilderExtensions.cs @@ -1,6 +1,8 @@ using Microsoft.Extensions.Logging; using Sentry; +using Sentry.Extensibility; using Sentry.Extensions.Logging; +using Sentry.Profiling; // ReSharper disable once CheckNamespace - Discoverability namespace Microsoft.AspNetCore.Components.WebAssembly.Hosting; @@ -28,10 +30,28 @@ public static WebAssemblyHostBuilder UseSentry(this WebAssemblyHostBuilder build blazorOptions.RequestBodyCompressionLevel = CompressionLevel.NoCompression; // Since the WebAssemblyHost is a client-side application blazorOptions.IsGlobalModeEnabled = true; + // If profiling enabled, disable it. + RemoveBlazorProfilingIntegration(blazorOptions); }); return builder; } + + private static void RemoveBlazorProfilingIntegration(SentryBlazorOptions options) + { + if (!options.IsProfilingEnabled) + { + return; + } + + options.SetupLogging(); + options.LogDebug("Profiling is Enabled in a Blazor WebAssembly application. " + + "Profiling integration has been removed from this project. " + + "Currently, profiling is not supported in Blazor WebAssembly applications. " + + "Check https://github.com/getsentry/sentry-dotnet/issues/4506 for more information."); + // Ensure project doesn't have Profiling Integration + options.RemoveIntegration(); + } } /// diff --git a/src/Sentry/Sentry.csproj b/src/Sentry/Sentry.csproj index f00de450ff..604f8edaae 100644 --- a/src/Sentry/Sentry.csproj +++ b/src/Sentry/Sentry.csproj @@ -13,7 +13,7 @@ $(TargetFrameworks);net9.0-ios18.0;net8.0-ios17.0 $(TargetFrameworks);net9.0-maccatalyst18.0;net8.0-maccatalyst17.0 - + @@ -148,6 +148,7 @@ + From 1adda76c782cf380822b55a3f646a383db4ba366 Mon Sep 17 00:00:00 2001 From: Alex Sohn Date: Tue, 9 Sep 2025 15:51:58 -0400 Subject: [PATCH 2/5] clarify wording in debug log --- .../WebAssemblyHostBuilderExtensions.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Sentry.AspNetCore.Blazor.WebAssembly/WebAssemblyHostBuilderExtensions.cs b/src/Sentry.AspNetCore.Blazor.WebAssembly/WebAssemblyHostBuilderExtensions.cs index 8d54efcf47..8c0625fa36 100644 --- a/src/Sentry.AspNetCore.Blazor.WebAssembly/WebAssemblyHostBuilderExtensions.cs +++ b/src/Sentry.AspNetCore.Blazor.WebAssembly/WebAssemblyHostBuilderExtensions.cs @@ -45,9 +45,8 @@ private static void RemoveBlazorProfilingIntegration(SentryBlazorOptions options } options.SetupLogging(); - options.LogDebug("Profiling is Enabled in a Blazor WebAssembly application. " + - "Profiling integration has been removed from this project. " + - "Currently, profiling is not supported in Blazor WebAssembly applications. " + + options.LogDebug("Detected Sentry profiling initialization in Blazor WebAssembly." + + "Sentry does not support Blazor WebAssembly profiling. Removing profiling integration." + "Check https://github.com/getsentry/sentry-dotnet/issues/4506 for more information."); // Ensure project doesn't have Profiling Integration options.RemoveIntegration(); From 7347afab4e48b2174046d42ae654a858c3132bb1 Mon Sep 17 00:00:00 2001 From: Alex Sohn Date: Tue, 9 Sep 2025 16:10:52 -0400 Subject: [PATCH 3/5] fix spaces between sentences --- .../WebAssemblyHostBuilderExtensions.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Sentry.AspNetCore.Blazor.WebAssembly/WebAssemblyHostBuilderExtensions.cs b/src/Sentry.AspNetCore.Blazor.WebAssembly/WebAssemblyHostBuilderExtensions.cs index 8c0625fa36..db1febde85 100644 --- a/src/Sentry.AspNetCore.Blazor.WebAssembly/WebAssemblyHostBuilderExtensions.cs +++ b/src/Sentry.AspNetCore.Blazor.WebAssembly/WebAssemblyHostBuilderExtensions.cs @@ -45,8 +45,8 @@ private static void RemoveBlazorProfilingIntegration(SentryBlazorOptions options } options.SetupLogging(); - options.LogDebug("Detected Sentry profiling initialization in Blazor WebAssembly." + - "Sentry does not support Blazor WebAssembly profiling. Removing profiling integration." + + options.LogDebug("Detected Sentry profiling initialization in Blazor WebAssembly. " + + "Sentry does not support Blazor WebAssembly profiling. Removing profiling integration. " + "Check https://github.com/getsentry/sentry-dotnet/issues/4506 for more information."); // Ensure project doesn't have Profiling Integration options.RemoveIntegration(); From 382536780578c63b944c7d9b44e17f30b3bd8aae Mon Sep 17 00:00:00 2001 From: Alex Sohn Date: Tue, 9 Sep 2025 16:14:03 -0400 Subject: [PATCH 4/5] Add disabling Blazor WASM profiling in CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e67270fd9d..ec3ea11f92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ - `InvalidOperationException` potentially thrown during a race condition, especially in concurrent high-volume logging scenarios ([#4428](https://github.com/getsentry/sentry-dotnet/pull/4428)) - Blocking calls are no longer treated as unhandled crashes ([#4458](https://github.com/getsentry/sentry-dotnet/pull/4458)) - Only apply Session Replay masks to specific control types when necessary to avoid performance issues in MAUI apps with complex UIs ([#4445](https://github.com/getsentry/sentry-dotnet/pull/4445)) +- Ensure profiling is disabled in Blazor WASM ([#4507](https://github.com/getsentry/sentry-dotnet/pull/4507)) ### Dependencies From 6450f44df1e25b8f588972bff78ca157c4b1b255 Mon Sep 17 00:00:00 2001 From: Alex Sohn Date: Tue, 9 Sep 2025 16:15:36 -0400 Subject: [PATCH 5/5] say WebAssembly of WASM in changelog.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec3ea11f92..42e4ffa46d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ - `InvalidOperationException` potentially thrown during a race condition, especially in concurrent high-volume logging scenarios ([#4428](https://github.com/getsentry/sentry-dotnet/pull/4428)) - Blocking calls are no longer treated as unhandled crashes ([#4458](https://github.com/getsentry/sentry-dotnet/pull/4458)) - Only apply Session Replay masks to specific control types when necessary to avoid performance issues in MAUI apps with complex UIs ([#4445](https://github.com/getsentry/sentry-dotnet/pull/4445)) -- Ensure profiling is disabled in Blazor WASM ([#4507](https://github.com/getsentry/sentry-dotnet/pull/4507)) +- Ensure profiling is disabled in Blazor WebAssembly ([#4507](https://github.com/getsentry/sentry-dotnet/pull/4507)) ### Dependencies