Breaking change docs: IHost.RunAsync/StopAsync throw when BackgroundService fails (.NET 11)#52863
Open
Breaking change docs: IHost.RunAsync/StopAsync throw when BackgroundService fails (.NET 11)#52863
Conversation
3 tasks
…groundService fails in .NET 11 Agent-Logs-Url: https://github.com/dotnet/docs/sessions/ba90f62b-c56b-4f77-ac69-71212d4fe526 Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix background service exception handling in host methods
Breaking change docs: IHost.RunAsync/StopAsync throw when BackgroundService fails (.NET 11)
Apr 3, 2026
gewarren
approved these changes
Apr 4, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new .NET 11 breaking change article under the Extensions area describing exception propagation from host-level run/stop/wait APIs when a BackgroundService fails, and wires the article into the .NET 11 breaking-change index and TOC.
Changes:
- Adds a new breaking change article documenting updated exception/exit-code behavior for
IHostrun/stop/wait APIs whenBackgroundService.ExecuteAsyncthrows. - Adds an Extensions section to the .NET 11 breaking changes index page and links the new article.
- Updates the compatibility TOC to include the new .NET 11 Extensions node and article link.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| docs/core/compatibility/toc.yml | Adds a .NET 11 Extensions TOC node pointing to the new breaking change article. |
| docs/core/compatibility/extensions/11.0/ihost-runasync-stopasync-throw-backgroundservice-failure.md | New breaking change article documenting the behavior change, rationale, recommended action, and affected APIs. |
| docs/core/compatibility/11.md | Adds an Extensions section and links the new breaking change article. |
...re/compatibility/extensions/11.0/ihost-runasync-stopasync-throw-backgroundservice-failure.md
Show resolved
Hide resolved
...re/compatibility/extensions/11.0/ihost-runasync-stopasync-throw-backgroundservice-failure.md
Show resolved
Hide resolved
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.
In .NET 11 Preview 3, when a
BackgroundService.ExecuteAsyncthrows andBackgroundServiceExceptionBehaviorisStopHost(default), the host-level async methods now propagate the exception instead of completing successfully—causing a non-zero exit code.Changes
docs/core/compatibility/extensions/11.0/ihost-runasync-stopasync-throw-backgroundservice-failure.mdAggregateExceptionfor multiple failures), reason (hiding failures was wrong), and migration path11.md: AddedExtensionssection (alphabetical order) referencing the new articletoc.yml: Added.NET 11 > ExtensionsentryRecommended action from the article
Do nothing—non-zero exit on failure is correct. To preserve the old success-exit behavior:
Affected APIs
HostingAbstractionsHostExtensions.RunAsync/Run/StopAsync/WaitForShutdownAsync/WaitForShutdownand the defaultIHost.StopAsyncimplementation.Internal previews