Repository navigation
Description
Build Information
Build: https://dev.azure.com/dnceng-public/cbb18261-c48f-4abb-8651-8cdcb5474649/_build/results?buildId=1346843
Build error leg or test failing: Microsoft.Extensions.Hosting.Internal.HostTests.StartCanBeCancelled
Pull request: https://github.com/dotnet/runtime.git/pull/125912
Error Message
Fill the error message using step by step known issues guidance.
{
"ErrorMessage": ["StartCanBeCancelled","Assert.True()"],
"ErrorPattern": "",
"BuildRetry": false,
"ExcludeConsoleLog": false
}Exception Message
Assert.True() Failure
Expected: True
Actual: False
CallStack
at Microsoft.Extensions.Hosting.Internal.HostTests.<StartCanBeCancelled>d__13.MoveNext() in /_/src/libraries/Microsoft.Extensions.Hosting/tests/UnitTests/Internal/HostTests.cs:line 297
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Known issue validation
Build: 🔎 https://dev.azure.com/dnceng-public/public/_build/results?buildId=1346843
Error message validated: [StartCanBeCancelled Assert.True()]
Result validation: ✅ Known issue matched with the provided build.
Validation performed at: 3/23/2026 12:52:32 AM UTC
Report
| Build | Definition | Test | Pull Request |
|---|---|---|---|
| 1346843 | dotnet/runtime | Microsoft.Extensions.Hosting.Internal.HostTests.StartCanBeCancelled | #125912 |
Summary
| 24-Hour Hit Count | 7-Day Hit Count | 1-Month Count |
|---|---|---|
| 1 | 1 | 1 |
Activity
danmoseley commentedon Mar 23, 2026
older issue #106135
edit: oops that looks like Core, this is net481-windows-Release-x86-NET481_Release-Windows.10.Amd64.Client.Open
dotnet-policy-service commentedon Mar 23, 2026
Tagging subscribers to this area: @dotnet/area-extensions-hosting
See info in area-owners.md if you want to be subscribed.
danmoseley commentedon Mar 23, 2026
Note
This analysis was generated with AI assistance (GitHub Copilot).
Analysis
Failing assertion: Line 296:
Assert.True(serviceStarting.WaitOne(TimeSpan.FromSeconds(5))). The stack trace reports "line 297" because .NET Framework's async state machine PDB mapping is off by one — line 297 iscts.Cancel()which cannot throwAssert.True() Failure.What it means:
host.StartAsync()didn't reach theFakeHostedService.StartActioncallback within 5 seconds. Looking atHost.StartAsync, before it reaches the hosted service'sStartAsyncit must:await _hostLifetime.WaitForStartAsync()IEnumerable<IHostedService>from DIawait ForeachServiceforStartingAsynclifecycle hooksawait ForeachServiceforStartAsync→FakeHostedService.StartAction→ setsserviceStartingEach
ConfigureAwait(false)continuation needs a ThreadPool thread.Why .NET Framework 4.8.1 specifically:
parallel test collections = on [2 threads]— other hosting tests compete for ThreadPool threadsRelationship to #106135: Same test, same symptom, but different context:
windows-x86 Release Libraries_NET481)MoveNext()/HandleNonSuccessAndDebuggerNotificationstack trace pattern confirms .NET FrameworkBackgroundService.StartAsyncto useTask.Run+ returnTask.CompletedTask— reducing ThreadPool pressure during Host startup. ButFakeHostedService(used in this test) isn't aBackgroundService, so the fix was indirect (reduced contention). The NET481 leg may not have benefited the same way.Fix options: Increase the 5s timeout to 30s (consistent with other hosting tests that were already bumped — see PR #43695, #59811), or replace
ManualResetEventwithTaskCompletionSource-based async signaling to avoid hard timeouts entirely.danmoseley commentedon Mar 23, 2026
Note
This analysis was generated with AI assistance (GitHub Copilot).
Why this test specifically?
All three
Task.Run(() => host.StartAsync(...))+WaitOne(5s)tests in HostTests.cs are structurally similar, but they signal at different points in theHost.StartAsyncpipeline:HostLifetimeOnStartedDelaysStartandHostLifetimeOnStartedCanBeCancelledsignal during step 1 —_hostLifetime.WaitForStartAsync()— the very first await inHost.StartAsync.StartCanBeCancelledsignals during step 4 — insideForeachServiceforStartAsync→FakeHostedService.StartAction. To get there, Host.StartAsync must first:await WaitForStartAsyncIEnumerable<IHostedService>from DIawait ForeachServiceforStartingAsynclifecycle hooksawait ForeachServiceforStartAsync→ signal fires hereEach
ConfigureAwait(false)continuation requires a ThreadPool thread on .NET Framework.StartCanBeCancelledneeds more async hops before the event fires, making it the most susceptible to ThreadPool pressure on the NET481 leg (x86, Framework ThreadPool ramps slowly at ~500ms/thread, 2 parallel test collections).danmoseley commentedon Mar 23, 2026
@copilot bump timeout for this specific test as suggested. your PR should close this issue