Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Blazor] Invoke inbound activity handlers on circuit initialization #57557

Merged
merged 2 commits into from
Sep 3, 2024

Conversation

MackinnonBuck
Copy link
Member

[Blazor] Invoke inbound activity handlers on circuit initialization

Fixes an issue where inbound activity handlers don't get invoked on circuit initialization.

Description

Note

This bug only affects Blazor Server apps, not Blazor Web apps utilizing server interactivity

Changes:

  • Updated CircuitHost to invoke inbound activity handlers on circuit initialization
  • Added an extra test to verify that inbound activity handlers work on the initial page load
  • Updated existing Blazor Web tests to reuse test logic from the non-web tests
    • The previous web-specific tests were not as elaborate, so this helps to ensure that the feature works the same way on Blazor Server and Blazor Web

Fixes #57481

@MackinnonBuck MackinnonBuck added the area-blazor Includes: Blazor, Razor Components label Aug 27, 2024
@MackinnonBuck MackinnonBuck requested a review from a team as a code owner August 27, 2024 22:26
@MackinnonBuck
Copy link
Member Author

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@MackinnonBuck
Copy link
Member Author

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@MackinnonBuck MackinnonBuck merged commit e2db47c into main Sep 3, 2024
27 checks passed
@MackinnonBuck MackinnonBuck deleted the mbuck/fix-inbound-activity-handlers branch September 3, 2024 18:42
@dotnet-policy-service dotnet-policy-service bot added this to the 10.0-preview1 milestone Sep 3, 2024
@MackinnonBuck
Copy link
Member Author

/backport to release/9.0

Copy link
Contributor

github-actions bot commented Sep 3, 2024

@MackinnonBuck
Copy link
Member Author

/backport to release/8.0

Copy link
Contributor

github-actions bot commented Sep 5, 2024

mkArtakMSFT pushed a commit that referenced this pull request Sep 5, 2024
…itialization (#57678)

Backport of #57557 to release/9.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:
* Monitoring inbound circuit activity
* Enabling server-side Blazor services to be [accessed from a different DI scope](https://learn.microsoft.com/aspnet/core/blazor/fundamentals/dependency-injection?view=aspnetcore-8.0#access-server-side-blazor-services-from-a-different-di-scope)

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:
* Updated `CircuitHost` to invoke inbound activity handlers on circuit initialization
* Added an extra test to verify that inbound activity handlers work on the initial page load
* Updated existing Blazor Web tests to reuse test logic from the non-web tests
  * This helps to ensure that the feature works the same way on Blazor Server and Blazor Web

Fixes #57481

## Customer Impact

The [initial issue report](#57481) 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?

- [ ] Yes
- [X] No

The problem has existed since the introduction of the feature in .NET 8.
## Risk

- [ ] High
- [ ] Medium
- [X] Low

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

- [X] Manual (required)
- [X] Automated

## Packaging changes reviewed?

- [ ] Yes
- [ ] No
- [x] N/A
mkArtakMSFT pushed a commit that referenced this pull request Sep 13, 2024
…itialization (#57715)

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:
* Monitoring inbound circuit activity
* Enabling server-side Blazor services to be [accessed from a different DI scope](https://learn.microsoft.com/aspnet/core/blazor/fundamentals/dependency-injection?view=aspnetcore-8.0#access-server-side-blazor-services-from-a-different-di-scope)

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:
* Updated `CircuitHost` to invoke inbound activity handlers on circuit initialization
* Added an extra test to verify that inbound activity handlers work on the initial page load
* Updated existing Blazor Web tests to reuse test logic from the non-web tests
  * This helps to ensure that the feature works the same way on Blazor Server and Blazor Web

Fixes #57481

## Customer Impact

The [initial issue report](#57481) 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?

- [ ] Yes
- [X] No

The problem has existed since the introduction of the feature in .NET 8.
## Risk

- [ ] High
- [ ] Medium
- [X] Low

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

- [X] Manual (required)
- [X] Automated

## Packaging changes reviewed?

- [ ] Yes
- [ ] No
- [x] N/A
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.

Blazor Server App - Problem with accessing request scope in DelegatingHandler
3 participants