Skip to content

Better errors for Blazor asset integrity problems#65613

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/improve-blazor-error-messages
Draft

Better errors for Blazor asset integrity problems#65613
Copilot wants to merge 2 commits intomainfrom
copilot/improve-blazor-error-messages

Conversation

Copy link
Contributor

Copilot AI commented Mar 2, 2026

When Blazor asset integrity checks fail (e.g., files modified after publish), users see the cryptic AggregateException_ctor_DefaultMessage resource key instead of a meaningful error.

Description

  • ResourceCollectionProvider.LoadResourceCollection(): Wraps JS interop calls in a try-catch. On failure, throws InvalidOperationException with a message identifying the URL and calling out file integrity mismatch as the likely cause:

    Failed to load the Blazor resource collection from '/_framework/resource-collection.abc123.js'.
    This is likely caused by a mismatch in the file integrity check, which can happen when files
    are modified after they are published. Ensure that all published files are deployed correctly
    and that none have been modified after publish.
    
  • HostedServiceExecutor.StopAsync(): new AggregateException(exceptions) had no message, causing the .NET resource key AggregateException_ctor_DefaultMessage to surface directly in trimmed WASM apps. Added "One or more hosted services failed to stop." as the explicit message.

  • Tests added for both changes (ResourceCollectionProviderTest, HostedServiceExecutorTest).

Original prompt

This section details on the original issue you should resolve

<issue_title>Better errors for Blazor asset integrity problems</issue_title>
<issue_description>### Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

See the report in #64923

The problem was due to a failed integrity check for changed file after publish. However, the error the user sees is a very non-descriptive AggregateException_ctor_DefaultMessage.

Describe the solution you'd like

The user should see an error explaining the actual reason.

Additional context

No response</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@github-actions github-actions bot added the needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically label Mar 2, 2026
- Wrap ResourceCollectionProvider.LoadResourceCollection() in try-catch to provide descriptive error when resource collection fails to load (e.g., due to integrity check failures)
- Fix HostedServiceExecutor.StopAsync() to include a message in the AggregateException instead of using the default (which shows as resource key AggregateException_ctor_DefaultMessage)
- Add tests for both changes

Co-authored-by: oroztocil <79744616+oroztocil@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve error messages for Blazor asset integrity issues Better errors for Blazor asset integrity problems Mar 2, 2026
@github-actions github-actions bot added area-blazor Includes: Blazor, Razor Components and removed needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically labels Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-blazor Includes: Blazor, Razor Components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Better errors for Blazor asset integrity problems

2 participants