microsoft/aspire · warning · OperationCanceledException
{cancellationMessage}
Error message
{cancellationMessage} What it means
Thrown by WaitForResourceCoreAsync when waiting for a resource condition (running/healthy/etc.) is cancelled. If cancellation came from an OperationCanceledException it is rethrown with an enriched message; otherwise it throws OperationCanceledException directly, indicating the wait ended without the condition ever being met.
Solutions
- Increase the timeout / cancellation budget around AppHost startup where applicable.
- Speed up resource startup (pre-pull images, simplify health checks) so waits complete before cancellation.
- Confirm the waitCondition target is actually attainable (e.g. resource exposes health endpoints for 'healthy').
- Catch OperationCanceledException in host code to distinguish user-initiated cancellation from genuine startup stalls.
Defensive patterns
Strategy: try-catch
Try / catch
try
{
await notificationService.WaitForResourceHealthyAsync(resourceName, cancellationToken);
}
catch (OperationCanceledException ex)
{
logger.LogWarning(ex, "Wait for '{ResourceName}' was cancelled before it became healthy.", resourceName);
} Prevention
- Grant startup enough time: avoid overly tight cancellation timeouts in CI/tests.
- Ensure the awaited condition is achievable (health endpoints exist for 'healthy').
- Speed up startup (image pre-pull, lighter health checks) to beat cancellation.
- Distinguish user-initiated cancels from stalls by logging the inner cancellation source.
When it happens
Trigger: WaitForResource/WaitForResourceHealthy/WaitUntil* calls whose CancellationToken fires (Ctrl+C, AppHost shutdown, host-level timeout) while the resource never reached the requested waitCondition; also the fall-through path when the wait completes without a satisfying event.
Common situations: Resource takes longer to start than the surrounding timeout allows (slow image pull, slow health check registration); user aborts `aspire run`; CI test harness cancels AppHost startup.
Understand the failure class
Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.
Related errors
- {cancellationMessage}
- Graceful budget cannot be negative.
- Resource ' ' failed to wait for dependencies before the…
- A circular lifetime reference was detected for resource
- A global MCP approval policy cannot be combined with custom…
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/9045cd5f5c2f1d78.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting/ApplicationModel/ResourceNotificationService.cs:693
{
continue;
}
activity.AddResourceWaitObserved(resourceEvent, waitCondition);
if (predicate(resourceEvent))
{
activity.AddResourceWaitCompleted(resourceEvent, waitCondition);
return resourceEvent;
}
}
}
catch (OperationCanceledException ex)
{
activity.AddResourceWaitCancelled(resourceName, waitCondition);
var errorMessage = BuildCancellationErrorMessage(cancellationMessage, resourceName);
throw new OperationCanceledException(errorMessage, ex, ex.CancellationToken);
}
throw new OperationCanceledException(BuildCancellationErrorMessage(cancellationMessage, resourceName));
}
private readonly object _onResourceUpdatedLock = new();
/// <summary>
/// Attempts to retrieve the current state of a resource by resourceId.
/// </summary>
/// <remarks>
/// <para>
/// A resource id can be either the unique id of the resource or the displayed resource name.
/// </para>
/// <para>
/// Projects, executables and containers typically have a unique id that combines the display name and a unique suffix. For example, a resource named <c>cache</c> could have a resource id of <c>cache-abcdwxyz</c>.
/// This id is used to uniquely identify the resource in the app host.
/// </para>
/// <para>View on GitHub (pinned to 25830f84bd)