[release/8.0] [Blazor] Invoke inbound activity handlers on circuit initialization #57715
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport of #57557 to release/8.0
[Blazor] Invoke inbound activity handlers on circuit initialization
Fixes an issue where inbound activity handlers don't get invoked on circuit initialization.
Note
This bug only affects Blazor Server apps, not Blazor Web apps utilizing server interactivity
Description
Inbound activity handlers were added in .NET 8 to enable:
However, prior to the fix in this PR, this feature didn't apply to the first interactive render after the initial page load. This means that when utilizing this feature to access Blazor services from a different DI scope, the service might only become accessible after subsequent renders, not the initial render.
This PR makes the following changes:
CircuitHost
to invoke inbound activity handlers on circuit initializationFixes #57481
Customer Impact
The initial issue report was from a customer who was impacted experiencing this problem in their app. The problem does not inherently cause an app to stop working, but if the application code has made the (rightful) assumption that the service accessor is initialized, then session may crash. The workaround is to upgrade the app to use the "Blazor Web App" pattern, although this can be a fairly large change.
Regression?
The problem has existed since the introduction of the feature in .NET 8.
Risk
The change is straightforward, and new tests have been added to ensure that it addresses the issue. Existing tests verify that a new regression is not introduced.
Verification
Packaging changes reviewed?