[CORRUPTED] Synthetic Benchmark PR #63814 - Support hosted services in WebAssemblyHost#30
Open
bar-qodo wants to merge 6 commits intobase_pr_63814_20260113_2357from
Open
Conversation
Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
This was referenced Jan 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Benchmark PR dotnet#63814
Type: Corrupted (contains bugs)
Original PR Title: Support hosted services in WebAssemblyHost
Original PR Description: This PR adds support for hosted services (
IHostedService) inWebAssemblyHost, enabling automatic startup and shutdown of background services in Blazor WebAssembly applications.Description
Applications using
WebAssemblyHost(e.g. Blazor WebAssembly clients) did not support hosted services out of the box. Services registered withAddHostedServicewere ignored when usingWebAssemblyHostBuilder, unlike in applications built withWebApplicationBuilderorHostApplicationBuilder. This prevented libraries like OpenTelemetry from working properly in Blazor WebAssembly apps, as they rely on hosted services for initialization.The implementation adds hosted service lifecycle management to
WebAssemblyHost:IHostedServiceimplementations from the DI containerRunAsyncCore()after component state restorationDisposeAsync()with proper error handlingWebAssemblyHostsimply resolves the executor from DI and calls it at the appropriate times, maintaining clean separation of concernsUsage
Developers can now register hosted services in Blazor WebAssembly apps:
Implementation Details
Microsoft.Extensions.Hosting.Abstractionsreference to enableIHostedServicesupportHostedServiceExecutorclass in the WebAssembly project to encapsulate hosted service lifecycle managementHostedServiceExecutoras a singleton in DI inWebAssemblyHostBuilder.InitializeDefaultServices()HostedServiceExecutoracceptsILogger<HostedServiceExecutor>and handles all exception aggregation and logging internallyWebAssemblyRendererandWebAssemblyNavigationManagerWebAssemblyHostresolves the executor from DI and coordinates its invocation at the right timesTesting
Added comprehensive test coverage:
All existing WebAssemblyHost functionality remains unchanged and all tests pass.
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.
Original PR URL: dotnet#63814