Skip to content

Conversation

@alexsohn1126
Copy link
Member

Fixes #3523:

Problem

We do not support profiling in Blazor WebAssembly apps. However, it was possible to pass initialize a Blazor WASM app with profiling, which led to undefined behaviours.

The issue above reported failing to publish Blazor WASM app when profiling is enabled. I was not able to replicate that, both in the current version of SDK, and also the version that the issue reporter was using (v4.9.0).

I did find that adding profiling in Blazor WASM led to errors in the browser:

image

Fix

Notify the user if they are using Sentry.Profiling in a Blazor WebAssembly project. If so, we throw an error pre-build, with a more descriptive message:

image

This was possible because Blazor WebAssembly apps have UsingMicrosoftNETSdkBlazorWebAssembly MSBuild property. See:

Testing Instructions

  • Include Sentry.Profiling package in a Blazor WebAssembly .csproj:

<PackageReference Include="Sentry.Profiling" Version="5.15.1"/>

  • At the bottom of the csproj file (before </Project>), import Sentry.Profiling.targets. In the case of samples/Sentry.Samples.AspNetCore.Blazor.Wasm.csproj:

<Import Project="..\..\src\Sentry.Profiling\buildTransitive\Sentry.Profiling.targets" />

  • If you try to build it, you should see the error shown in the Fix section.

See also:

@alexsohn1126 alexsohn1126 changed the title Throw error when building Blazor WASM with Profiling fix: disallow building Blazor WASM with Profiling Sep 11, 2025
@codecov
Copy link

codecov bot commented Sep 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.43%. Comparing base (e1f9b5f) to head (0eea9ca).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4512   +/-   ##
=======================================
  Coverage   73.43%   73.43%           
=======================================
  Files         479      479           
  Lines       17506    17506           
  Branches     3480     3480           
=======================================
  Hits        12856    12856           
  Misses       3772     3772           
  Partials      878      878           

☔ 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.

Copy link
Collaborator

@jamescrosswell jamescrosswell left a comment

Choose a reason for hiding this comment

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

LGTM - thanks @alexsohn1126 !

@jamescrosswell jamescrosswell merged commit 3181dc3 into main Sep 11, 2025
16 of 17 checks passed
@jamescrosswell jamescrosswell deleted the alexsohn/fix/fail-build-when-profiling-with-blazor-wasm branch September 11, 2025 23:39
@github-actions
Copy link
Contributor

Fails
🚫 Please consider adding a changelog entry for the next release.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

Example:

## Unreleased

- disallow building Blazor WASM with Profiling ([#4512](https://github.com/getsentry/sentry-dotnet/pull/4512))

If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description or adding a skip-changelog label.

Generated by 🚫 dangerJS against 0eea9ca

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Blazor publish fails when using profiling

3 participants