UnrealBuildTool crashing on single file compile

I was pleased to discover that the Unreal Unity build system had a single file compilation option, however I was dismayed to discover that compiling a single file generally takes more than 10 seconds, due to the overhead of the Unity build. I was hopeful that the upgrade to 4.22 might improve that overhead, however, in practice, it seems that single file compile is just completely broken for me now. Here is the output I see:

1>  UnrealBuildTool: ERROR: Unhandled exception: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
1>                             at System.ThrowHelper.ThrowKeyNotFoundException()
1>                             at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
1>                             at UnrealBuildTool.HotReload.ApplyState(HotReloadState HotReloadState, TargetMakefile Makefile) in D:\depot\dev\prototype\Engine\Source\Programs\UnrealBuildTool\System\HotReload.cs:line 320
1>                             at UnrealBuildTool.BuildMode.GetActionsForTarget(BuildConfiguration BuildConfiguration, TargetDescriptor TargetDescriptor, TargetMakefile Makefile) in D:\depot\dev\prototype\Engine\Source\Programs\UnrealBuildTool\Modes\BuildMode.cs:line 532
1>                             at UnrealBuildTool.BuildMode.Build(List`1 TargetDescriptors, BuildConfiguration BuildConfiguration, ISourceFileWorkingSet WorkingSet, BuildOptions Options) in D:\depot\dev\prototype\Engine\Source\Programs\UnrealBuildTool\Modes\BuildMode.cs:line 242
1>                             at UnrealBuildTool.BuildMode.Execute(CommandLineArguments Arguments) in D:\depot\dev\prototype\Engine\Source\Programs\UnrealBuildTool\Modes\BuildMode.cs:line 191
1>                             at UnrealBuildTool.UnrealBuildTool.Main(String[] ArgumentsArray) in D:\depot\dev\prototype\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.cs:line 443

Something wrong happening with hot reload, close editor and then try to compile, potentially this can fix things up considering changed compilation settings

As you suggest, the problem does not occur when the editor is not running, though that makes the feature significantly less useful. The ideal scenario is that I would be able to do an arbitrary number of very fast compiles, and then once the code was in a compile-bug-free state, a successful hot reload. I wouldn’t mind if I had to initiate the hot reload myself.

Ok do you still got a issue after successful compile?

Well, yes, if you are in the editor, then the error occurs as it did in the first place. I can’t tell whether you are suggesting that the feature should not work when the editor is running.

I think I should be more definite here and say that I don’t think doing a “single file compile” (pressing Ctrl-F7, as the docs suggest we map this functionality to, to emulate the standard VS behavior) should initiate a hot reload. Pressing Ctrl-F7 in VS does not cause any linking to happen at all. That’s why it’s fast, and it’s useful because it’s fast. We need a way to compile something fast. Hot reload should not be involved.

same error as @Robert_Marr in UE4.27.2. However, it works with editor open in UE5.0.0 preview 2