Skip to content

Commit 8e27940

Browse files
authored
Fixes a race in extension startup (#38156)
This only repros on my desktop, so I suppose that means a slower machine is needed I was mistaken, and assumed we were already operating on a copy here. We weren't. That meant that it was possible for another extension to be detected, change the list, and crash the whole palette. ## Validation Steps Performed No longer does my desktop crash on startup
1 parent c6750d3 commit 8e27940

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/TopLevelCommandManager.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The Microsoft Corporation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using System.Collections.Immutable;
56
using System.Collections.ObjectModel;
67
using CommunityToolkit.Mvvm.ComponentModel;
78
using CommunityToolkit.Mvvm.Input;
@@ -209,7 +210,7 @@ public async Task<bool> LoadExtensionsAsync()
209210
extensionService.OnExtensionAdded -= ExtensionService_OnExtensionAdded;
210211
extensionService.OnExtensionRemoved -= ExtensionService_OnExtensionRemoved;
211212

212-
var extensions = await extensionService.GetInstalledExtensionsAsync();
213+
var extensions = (await extensionService.GetInstalledExtensionsAsync()).ToImmutableList();
213214
_extensionCommandProviders.Clear();
214215
if (extensions != null)
215216
{
@@ -241,6 +242,7 @@ private async Task StartExtensionsAndGetCommands(IEnumerable<IExtensionWrapper>
241242
// TODO This most definitely needs a lock
242243
foreach (var extension in extensions)
243244
{
245+
Logger.LogDebug($"Starting {extension.PackageFullName}");
244246
try
245247
{
246248
// start it ...

0 commit comments

Comments
 (0)