Skip to content

Add aspire new diagnostic logging#17570

Draft
sebastienros wants to merge 1 commit into
release/13.4from
sebros/diagnose-aspire-new-hang
Draft

Add aspire new diagnostic logging#17570
sebastienros wants to merge 1 commit into
release/13.4from
sebros/diagnose-aspire-new-hang

Conversation

@sebastienros
Copy link
Copy Markdown
Contributor

@sebastienros sebastienros commented May 28, 2026

Description

Adds diagnostic logging for the aspire new TypeScript AppHost creation path so future hangs or version-skew failures can be localized from debug logs instead of stopping at "Starting JsonRpc server on Unix domain socket".

The logs now show:

  • Template package candidate counts/previews, selected version, channel, and reason (exact current CLI match, current CLI pin, or latest fallback).
  • AppHost package restore diagnostics for Aspire.Hosting, Aspire.Hosting.CodeGeneration.TypeScript, and Aspire.TypeSystem, including the probe manifest path.
  • AppHost server process/socket lifecycle, RPC transport connection, authentication, and RPC method elapsed time/slow-wait warnings.
  • Remote host JsonRpc connection accept/listen/cleanup diagnostics.

Manual diagnosis with the instrumented CLI showed the current fixed release/13.4 path selects template/package version 13.4.0 for --channel daily via current CLI pin, restores matching 13.4.0 AppHost packages, connects/authenticates successfully, and completes scaffoldAppHost in 8 ms. A temporary local revert of the current-CLI pinning fallback selected 13.5.0-preview.1.26277.15 from daily via latest fallback, restored Aspire.Hosting, Aspire.Hosting.CodeGeneration.TypeScript, and Aspire.TypeSystem 13.5.0-preview.1.26277.15, then still connected/authenticated successfully and completed scaffoldAppHost in 10 ms and generateCode in 65 ms. Forced pre-fix style runs with --version 13.5.0-preview.1.26277.12 and .15 produced the same successful RPC-boundary result in the current environment, so the earlier hang is not reproducing here.

Fixes # (issue)

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

Add bounded diagnostics for template version selection, AppHost package restore, AppHost server startup, RPC connection/authentication, and scaffold RPC calls so hangs during polyglot project creation can be localized from debug logs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 28, 2026 00:29
@github-actions
Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 17570

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 17570"

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds diagnostic logging across the aspire new TypeScript AppHost creation path to make template/package selection, restore, server lifecycle, transport connection, authentication, and RPC waits easier to diagnose.

Changes:

  • Adds reusable diagnostic helpers for slow-task warnings and restored AppHost package version logging.
  • Instruments template resolution, AppHost preparation/build/restore, RPC connection/authentication/invocation, and RemoteHost JSON-RPC connection lifecycle.
  • Updates tests that construct TemplateNuGetConfigService to pass a NullLogger.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Aspire.Cli/Commands/NewCommand.cs Logs template channel discovery, candidate previews, and selected template version reason.
src/Aspire.Cli/NuGet/BundleNuGetService.cs Logs restored AppHost package versions after cached or fresh bundle restores.
src/Aspire.Cli/Projects/AppHostRpcClient.cs Adds RPC transport/authentication/method timing diagnostics and slow-wait warnings.
src/Aspire.Cli/Projects/AppHostServerSession.cs Logs AppHost server process/session preparation and wraps slow operations with warnings.
src/Aspire.Cli/Projects/DotNetBasedAppHostServerProject.cs Logs in-repo AppHost preparation and restored package versions.
src/Aspire.Cli/Projects/PrebuiltAppHostServer.cs Logs prebuilt AppHost package/project-reference preparation diagnostics.
src/Aspire.Cli/Templating/TemplateNuGetConfigService.cs Adds logging for template package resolution candidates and selection reasons.
src/Aspire.Cli/Utils/AppHostPackageDiagnostics.cs Adds helper for reading and formatting tracked AppHost package versions from assets files.
src/Aspire.Cli/Utils/DiagnosticLogging.cs Adds helper for emitting one-time slow-operation warnings without changing task results.
src/Aspire.Hosting.RemoteHost/JsonRpcServer.cs Enriches JSON-RPC connection accept/listen/cleanup debug logs.
tests/Aspire.Cli.Tests/Templating/DotNetTemplateFactoryTests.cs Updates test construction for the new TemplateNuGetConfigService logger dependency.
tests/Aspire.Cli.Tests/Templating/TemplateNuGetConfigServiceTests.cs Updates test helper construction for the new logger dependency.

Comment on lines +75 to +79
foreach (var library in libraries.EnumerateObject())
{
if (!library.Value.TryGetProperty("type", out var typeElement) ||
!string.Equals(typeElement.GetString(), "package", StringComparison.OrdinalIgnoreCase) ||
TryParseLibraryName(library.Name) is not { } package)
Comment on lines +11 to +18
public static async Task<T> WaitWithSlowWarningAsync<T>(Task<T> task, TimeSpan threshold, Action logWarning)
{
ArgumentNullException.ThrowIfNull(task);
ArgumentNullException.ThrowIfNull(logWarning);

using var delayCancellation = new CancellationTokenSource();
var delayTask = Task.Delay(threshold, delayCancellation.Token);
if (await Task.WhenAny(task, delayTask).ConfigureAwait(false) == delayTask && !task.IsCompleted)
// The backchannel listener registers handlers without a connection name, so this value
// is purely for grouping client-side spans/metrics in the trace.
private const string ConnectionName = "remotehost";
private static readonly TimeSpan s_slowOperationWarningThreshold = TimeSpan.FromSeconds(5);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not slow

@github-actions
Copy link
Copy Markdown
Contributor

CLI E2E Tests failed — 105 passed, 2 failed, 2 unknown (commit 2c70702)

Failed Tests

View all recordings
Status Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View recording
AddPackageWhileAppHostRunningDetached ▶️ View recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View recording
AgentInitCommand_DefaultSelection_InstallsDefaultSkills ▶️ View recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View recording
AgentMcpListStructuredLogsReturnsLogsFromStarterApp ▶️ View recording
AgentMcpListStructuredLogsReturnsLogsFromStarterApp_DevLocalhost ▶️ View recording
AgentMcpListStructuredLogsReturnsLogsFromStarterApp_Isolated ▶️ View recording
AllPublishMethodsBuildDockerImages ▶️ View recording
AspireAddAndStartWorkAgainstLegacyAppHostTs ▶️ View recording
AspireAddPackageVersionToDirectoryPackagesProps ▶️ View recording
AspireInitSingleFileAppHostRunsViaDotnetRunAppHost ▶️ View recording
AspireInitWithExistingAppHostDirRecreatesMissingNuGetConfigAndPreservesFiles ▶️ View recording
AspireInitWithSolutionFileGeneratesAppHostThatBuildsAgainstChannelHive ▶️ View recording
AspireStartUpdatesStaleTypeScriptAppHostPath ▶️ View recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View recording
AspireUpdateRemovesOrphanAppHostPackageVersionWhenSdkAlreadyCurrent ▶️ View recording
Banner_DisplayedOnFirstRun ▶️ View recording
Banner_DisplayedWithExplicitFlag ▶️ View recording
Banner_NotDisplayedWithNoLogoFlag ▶️ View recording
CertificatesClean_RemovesCertificates ▶️ View recording
CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate ▶️ View recording
CertificatesTrust_WithUntrustedCert_TrustsCertificate ▶️ View recording
ConfigSetGet_CreatesNestedJsonFormat ▶️ View recording
CreateAndRunAspireStarterProject ▶️ View recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View recording
CreateAndRunEmptyAppHostProject ▶️ View recording
CreateAndRunJavaEmptyAppHostProject ▶️ View recording
CreateAndRunJsReactProject ▶️ View recording
CreateAndRunPythonReactProject ▶️ View recording
CreateAndRunTypeScriptEmptyAppHostProject ▶️ View recording
CreateAndRunTypeScriptStarterProject ▶️ View recording
CreateJavaAppHostWithViteApp ▶️ View recording
CreateTypeScriptAppHostWithViteApp_AllowsGuestAppPackageManagerToDiffer ▶️ View recording
CreateTypeScriptAppHostWithViteApp_UsesConfiguredToolchain ▶️ View recording
DashboardRunWithAgentMcpListTracesReturnsNoTraces ▶️ View recording
DashboardRunWithAgentMcpListTracesReturnsNoTraces_DevLocalhost ▶️ View recording
DashboardRunWithOtelTracesReturnsNoTraces ▶️ View recording
DashboardRunWithOtelTracesReturnsNoTraces_DevLocalhost ▶️ View recording
DeployK8sBasicApiService ▶️ View recording
DeployK8sWithExternalHelmChart ▶️ View recording
DeployK8sWithGarnet ▶️ View recording
DeployK8sWithMongoDB ▶️ View recording
DeployK8sWithMySql ▶️ View recording
DeployK8sWithPostgres ▶️ View recording
DeployK8sWithRabbitMQ ▶️ View recording
DeployK8sWithRedis ▶️ View recording
DeployK8sWithSqlServer ▶️ View recording
DeployK8sWithValkey ▶️ View recording
DeployTypeScriptAppToKubernetes ▶️ View recording
DescribeCommandResolvesReplicaNames ▶️ View recording
DescribeCommandShowsRunningResources ▶️ View recording
DetachFormatJsonProducesValidJson ▶️ View recording
DetachFormatJsonProducesValidJsonWhenRestartingExistingInstance ▶️ View recording
DoPublishAndDeployListStepsWork ▶️ View recording
DocsCommand_RendersInteractiveMarkdownFromLocalSource ▶️ View recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View recording
DoctorCommand_TypeScriptAppHostReportsMissingConfiguredToolchain ▶️ View recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View recording
GatewayWithoutExternalEndpoint_FailsPublishWithGuidance ▶️ View recording
GeneratedAspireDevScript_StartsWatchMode_WithConfiguredToolchain ▶️ View recording
GlobalMigration_HandlesCommentsAndTrailingCommas ▶️ View recording
GlobalMigration_HandlesMalformedLegacyJson ▶️ View recording
GlobalMigration_PreservesAllValueTypes ▶️ View recording
GlobalMigration_SkipsWhenNewConfigExists ▶️ View recording
GlobalSettings_MigratedFromLegacyFormat ▶️ View recording
IngressWithoutExternalEndpoint_FailsPublishWithGuidance ▶️ View recording
InitTypeScriptAppHost_AugmentsExistingViteRepoInWorkspaceSubdirectory ▶️ View recording
InteractiveCSharpInitCreatesExpectedFiles ▶️ View recording
InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View recording
JavaScriptHostingApisRunFromTypeScriptAppHost ▶️ View recording
LatestCliCanStartStableChannelAppHost ▶️ View failure recording
LatestCliCanStartStableChannelTypeScriptAppHost ▶️ View failure recording
LegacySettingsMigration_AdjustsRelativeAppHostPath ▶️ View recording
LogsCommandShowsResourceLogs ▶️ View recording
OtelLogsReturnsStructuredLogsFromStarterApp ▶️ View recording
OtelLogsReturnsStructuredLogsFromStarterAppIsolated ▶️ View recording
PsCommandListsRunningAppHost ▶️ View recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View recording
PublishJavaScriptPatternsGeneratesExpectedDockerComposeArtifacts ▶️ View recording
PublishWithConfigureEnvFileUpdatesEnvOutput ▶️ View recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View recording
PublishWithoutOutputPathUsesAppHostDirectoryDefault ▶️ View recording
ResourceCommand_FailedExecution_DisplaysAppHostLogPathAndLogContainsEntries ▶️ View recording
ResourceCommand_SetAndDeleteParameterUpdatesDescribeOutput ▶️ View recording
RestoreGeneratesSdkFiles ▶️ View recording
RestoreGeneratesSdkFiles_WithConfiguredToolchain ▶️ View recording
RestoreRefreshesGeneratedSdkAfterAddingIntegration ▶️ View recording
RestoreSupportsConfigOnlyHelperPackageAndCrossPackageTypes ▶️ View recording
RunFromParentDirectory_UsesExistingConfigNearAppHost ▶️ View recording
RunReportsSyntaxErrorsForDotNetAppHost ▶️ View recording
RunReportsSyntaxErrorsForTypeScriptAppHost ▶️ View recording
SecretCrudOnDotNetAppHost ▶️ View recording
SecretCrudOnTypeScriptAppHost ▶️ View recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View recording
StartAndWaitForTypeScriptSqlServerAppHostWithNativeAssets ▶️ View recording
StartReportsSyntaxErrorsForDotNetAppHost ▶️ View recording
StartReportsSyntaxErrorsForTypeScriptAppHost ▶️ View recording
StopAllAppHostsFromAppHostDirectory ▶️ View recording
StopJavaPolyglotAppHostUsingApphostDirectory ▶️ View recording
StopNonInteractiveSingleAppHost ▶️ View recording
StopTypeScriptPolyglotAppHostUsingApphostDirectory ▶️ View recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View recording
UnAwaitedChainsCompileWithAutoResolvePromises ▶️ View recording
UpdateProjectChannelToStable_CSharpEmptyAppHost_PreservesAspireConfigChannel ▶️ View recording
UpdateProjectChannelToStable_CSharpSingleFileInit_PreservesAspireConfigChannel ▶️ View recording
UpdateProjectChannelToStable_TypeScriptSingleFileInit_PreservesAspireConfigChannel ▶️ View recording
UpdateProjectChannelToStable_TypeScript_PreviewsStablePackagesAndPreservesChannel ▶️ View recording

📹 Recordings uploaded automatically from CI run #26546999604

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants