Skip to content

dotnet watch crashes with "An unexpected error ocurred" #47392

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
rogihee opened this issue Mar 9, 2025 · 7 comments
Open

dotnet watch crashes with "An unexpected error ocurred" #47392

rogihee opened this issue Mar 9, 2025 · 7 comments
Labels
Area-Watch untriaged Request triage from a team member

Comments

@rogihee
Copy link

rogihee commented Mar 9, 2025

Describe the bug

While working on my program I was working on modifying some blazor components, nothing fancy: just copying a blazor component, modifying the name, changeing the type of a parameter.

When I looked at the dotnet watch log it has crashed.

dotnet watch ❌ System.ArgumentException: Cannot find the old value (Parameter 'oldValue')
   at System.Collections.Immutable.ImmutableArray`1.Replace(T oldValue, T newValue, IEqualityComparer`1 equalityComparer)
   at System.Collections.Immutable.ImmutableArray`1.Replace(T oldValue, T newValue)
   at Microsoft.CodeAnalysis.GeneratorDriver.ReplaceAdditionalText(AdditionalText oldText, AdditionalText newText)
   at Microsoft.CodeAnalysis.SolutionCompilationState.TranslationAction.TouchAdditionalDocumentsAction.TransformGeneratorDriver(GeneratorDriver generatorDriver)
   at Microsoft.CodeAnalysis.SolutionCompilationState.RegularCompilationTracker.<>c__DisplayClass24_0.<<GetOrBuildFinalStateAsync>g__ApplyFirstTransformationAsync|6>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.CodeAnalysis.SolutionCompilationState.RegularCompilationTracker.<>c__DisplayClass24_0.<<GetOrBuildFinalStateAsync>g__CollapseInProgressStateAsync|2>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.CodeAnalysis.SolutionCompilationState.RegularCompilationTracker.<>c__DisplayClass24_0.<<GetOrBuildFinalStateAsync>g__BuildFinalStateAsync|0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.CodeAnalysis.SolutionCompilationState.RegularCompilationTracker.GetOrBuildFinalStateAsync(SolutionCompilationState compilationState, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.SolutionCompilationState.RegularCompilationTracker.GetCompilationSlowAsync(SolutionCompilationState compilationState, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.SolutionCompilationState.GetMetadataReferenceAsync(ICompilationTracker tracker, ProjectState fromProject, ProjectReference projectReference, Boolean includeCrossLanguage, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.SolutionCompilationState.RegularCompilationTracker.<>c__DisplayClass24_0.<<GetOrBuildFinalStateAsync>g__FinalizeCompilationWorkerAsync|4>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.CodeAnalysis.SolutionCompilationState.RegularCompilationTracker.<>c__DisplayClass24_0.<<GetOrBuildFinalStateAsync>g__FinalizeCompilationAsync|3>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.CodeAnalysis.SolutionCompilationState.RegularCompilationTracker.<>c__DisplayClass24_0.<<GetOrBuildFinalStateAsync>g__BuildFinalStateAsync|0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.CodeAnalysis.SolutionCompilationState.RegularCompilationTracker.GetOrBuildFinalStateAsync(SolutionCompilationState compilationState, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.SolutionCompilationState.RegularCompilationTracker.GetCompilationSlowAsync(SolutionCompilationState compilationState, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.SolutionCompilationState.GetMetadataReferenceAsync(ICompilationTracker tracker, ProjectState fromProject, ProjectReference projectReference, Boolean includeCrossLanguage, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.SolutionCompilationState.RegularCompilationTracker.<>c__DisplayClass24_0.<<GetOrBuildFinalStateAsync>g__FinalizeCompilationWorkerAsync|4>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.CodeAnalysis.SolutionCompilationState.RegularCompilationTracker.<>c__DisplayClass24_0.<<GetOrBuildFinalStateAsync>g__FinalizeCompilationAsync|3>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.CodeAnalysis.SolutionCompilationState.RegularCompilationTracker.<>c__DisplayClass24_0.<<GetOrBuildFinalStateAsync>g__BuildFinalStateAsync|0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.CodeAnalysis.SolutionCompilationState.RegularCompilationTracker.GetOrBuildFinalStateAsync(SolutionCompilationState compilationState, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.SolutionCompilationState.RegularCompilationTracker.GetCompilationSlowAsync(SolutionCompilationState compilationState, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.SolutionCompilationState.GetMetadataReferenceAsync(ICompilationTracker tracker, ProjectState fromProject, ProjectReference projectReference, Boolean includeCrossLanguage, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.SolutionCompilationState.RegularCompilationTracker.<>c__DisplayClass24_0.<<GetOrBuildFinalStateAsync>g__FinalizeCompilationWorkerAsync|4>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.CodeAnalysis.SolutionCompilationState.RegularCompilationTracker.<>c__DisplayClass24_0.<<GetOrBuildFinalStateAsync>g__FinalizeCompilationAsync|3>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.CodeAnalysis.SolutionCompilationState.RegularCompilationTracker.<>c__DisplayClass24_0.<<GetOrBuildFinalStateAsync>g__BuildFinalStateAsync|0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.CodeAnalysis.SolutionCompilationState.RegularCompilationTracker.GetOrBuildFinalStateAsync(SolutionCompilationState compilationState, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.SolutionCompilationState.RegularCompilationTracker.GetSourceGeneratorDiagnosticsAsync(SolutionCompilationState compilationState, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.EditAndContinue.EditSession.GetSourceGeneratedDocumentStatesAsync(Project project, ArrayBuilder`1 diagnostics, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.EditAndContinue.EditSession.PopulateChangedAndAddedDocumentsAsync(Project oldProject, Project newProject, ArrayBuilder`1 changedOrAddedDocuments, ArrayBuilder`1 diagnostics, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.EditAndContinue.EditSession.EmitSolutionUpdateAsync(Solution solution, ActiveStatementSpanProvider solutionActiveStatementSpanProvider, UpdateId updateId, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.EditAndContinue.DebuggingSession.EmitSolutionUpdateAsync(Solution solution, IImmutableSet`1 runningProjects, ActiveStatementSpanProvider activeStatementSpanProvider, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.ExternalAccess.Watch.Api.WatchHotReloadService.GetUpdatesAsync(Solution solution, IImmutableSet`1 runningProjects, CancellationToken cancellationToken)
   at Microsoft.DotNet.Watch.CompilationHandler.HandleFileChangesAsync(Func`3 restartPrompt, CancellationToken cancellationToken)
   at Microsoft.DotNet.Watch.HotReloadDotNetWatcher.WatchAsync(CancellationToken shutdownCancellationToken)
   at Microsoft.DotNet.Watch.HotReloadDotNetWatcher.WatchAsync(CancellationToken shutdownCancellationToken)
   at Microsoft.DotNet.Watch.HotReloadDotNetWatcher.WatchAsync(CancellationToken shutdownCancellationToken)
   at Microsoft.DotNet.Watch.Program.RunAsync()
dotnet watch ❌ An unexpected error occurred

dotnet info:

.NET SDK:
 Version:           9.0.200
 Commit:            90e8b202f2
 Workload version:  9.0.200-manifests.69179adf
 MSBuild version:   17.13.8+cbc39bea8

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19045
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\9.0.200\

.NET workloads installed:
 [ios]
   Installation Source: VS 17.12.35309.182, VS 17.13.35818.85
   Manifest Version:    18.2.9180/9.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.ios\18.2.9180\WorkloadManifest.json
   Install Type:              Msi

 [android]
   Installation Source: VS 17.12.35309.182, VS 17.13.35818.85
   Manifest Version:    35.0.39/9.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.android\35.0.39\WorkloadManifest.json
   Install Type:              Msi

 [maui-windows]
   Installation Source: VS 17.12.35309.182, VS 17.13.35818.85
   Manifest Version:    9.0.14/9.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.maui\9.0.14\WorkloadManifest.json
   Install Type:              Msi

 [maccatalyst]
   Installation Source: VS 17.12.35309.182, VS 17.13.35818.85
   Manifest Version:    18.2.9180/9.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.maccatalyst\18.2.9180\WorkloadManifest.json
   Install Type:              Msi

 [wasm-tools]
   Installation Source: VS 17.13.35818.85
   Manifest Version:    9.0.2/9.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.workload.mono.toolchain.current\9.0.2\WorkloadManifest.json
   Install Type:              Msi

 [wasm-tools-net8]
   Installation Source: VS 17.13.35818.85
   Manifest Version:    9.0.2/9.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.workload.mono.toolchain.net8\9.0.2\WorkloadManifest.json
   Install Type:              Msi

 [aspire]
   Installation Source: VS 17.13.35818.85
   Manifest Version:    8.2.2/8.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.aspire\8.2.2\WorkloadManifest.json
   Install Type:              Msi

Configured to use loose manifests when installing new manifests.

Host:
  Version:      9.0.2
  Architecture: x64
  Commit:       80aa709f5d

.NET SDKs installed:
  5.0.103 [C:\Program Files\dotnet\sdk]
  5.0.203 [C:\Program Files\dotnet\sdk]
  5.0.214 [C:\Program Files\dotnet\sdk]
  6.0.321 [C:\Program Files\dotnet\sdk]
  7.0.203 [C:\Program Files\dotnet\sdk]
  8.0.406 [C:\Program Files\dotnet\sdk]
  9.0.100-rc.1.24452.12 [C:\Program Files\dotnet\sdk]
  9.0.200 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.26 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.27 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.26 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.27 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0-rc.1.20451.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.33 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.0-rc.1.24452.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0-rc.1.20451.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.33 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.0-rc.1.24431.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.33 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 9.0.0-rc.1.24452.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 9.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  arm64 [C:\Program Files\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\arm64\InstallLocation]
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  Not found

Exceptions (if any)

Further technical details

  • Include the output of dotnet --info
  • The IDE (VS / VS Code/ VS4Mac) you're running on, and its version
@ghost ghost added Area-Workloads untriaged Request triage from a team member labels Mar 9, 2025
@tmat
Copy link
Member

tmat commented Mar 11, 2025

@chsienki @jasonmalinowski ptal

@chsienki
Copy link
Member

@tmat @jasonmalinowski Looks like the IDE/watch is attempting to replace an additional document that the generator doesn't know about, so something has gotten out of sync.

@jasonmalinowski
Copy link
Member

Hmm that's definitely not good. @tmat @chsienki any idea how easy this would be to reproduce? And any way to get a crash dump when the exception happens?

@tmat
Copy link
Member

tmat commented Mar 11, 2025

@rogihee Mentions the following steps:
"just copying a blazor component, modifying the name, changing the type of a parameter."

You can attach to dotnet-watch process or monitor for exception via procdump

@rogihee
Copy link
Author

rogihee commented Mar 11, 2025

@tmat thanks, will have a go again.

Nowadays I usually try to avoid using dotnet watch during most of my workflow, because it is finicky. And limit it to only frontend part of development of a (Blazor) feature.

But as an experiment I now started when I began a new feature branch. That involved in this case copy-pasting 2 files to have a beginning of a new feature, quickly renaming it. Just doing stuff that will definitely not build. It was during this the exception was thrown.

@tmat
Copy link
Member

tmat commented Mar 11, 2025

because it is finicky

Would you mind elaborating? Does 9.0.200 feel better?

@rogihee
Copy link
Author

rogihee commented Mar 11, 2025

With 9.0.100 it was unworkable because Razor Class Libraries were not included in the watch profile due to a bug. This was my first attempt again in 3 months to use it again, and bumped into this after 5 minutes. So I don't have much mileage yet. My colleague says it's definitely better but still sometimes crashing / not working.

Mostly you @tmat did a ton of effort in 9.0.200, been following the changes. Me and my colleagues would REALLY love to have good solid, reliable dotnet watch with Hot Reload.

I'll do my best to use it again in my daily workflow and try to reproduce issues or attach procdump when it crashes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Watch untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

5 participants