Inconsistent IHostedService ordering between WebHost and Host #11437
Labels
area-hosting
Includes Hosting
area-networking
Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
breaking-change
This issue / pr will introduce a breaking change, when resolved / merged.
Done
This issue has been fixed
Milestone
In WebHost IHostedServices run after IServer. We've had a lot of complaints about that and we're considering reversing that in 3.0 to be more consistent with generic Host where they run in registration order.
In generic Host IServer is part of an IHostedService GenericWebHostService and gets registered before any IHostedServices from Startup, the user doesn't get to control that. They can only control the ordering of services registered directly with the Host in Program.
Proposal: delay registering GenericWebHostService until after the app is done registering.
https://github.com/aspnet/AspNetCore/blob/56ffc6b58210292a18f548bf4eddff193f73a4d6/src/Hosting/Hosting/src/GenericHost/GenericWebHostBuilder.cs#L78
https://github.com/aspnet/AspNetCore/blob/56ffc6b58210292a18f548bf4eddff193f73a4d6/src/Hosting/Hosting/src/GenericHostWebHostBuilderExtensions.cs#L11-L13
@davidfowl
The text was updated successfully, but these errors were encountered: