From 4489677b6418801ab36681c5d8876c890811ad01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Pol=C3=A1=C5=A1ek?= Date: Mon, 28 Jul 2025 23:18:04 +0200 Subject: [PATCH] CmdPal: Add error handling to extension disposal (#40825) ## Summary of the Pull Request Ensure that errors encountered while sending the extension disposal signal are handled gracefully. If an error occurs when disposing of a particular extension, continue signaling the remaining extensions rather than halting the entire process. This prevents a single failure from interrupting the disposal chain and improves overall robustness. ## PR Checklist - [ ] Closes: #xxx - [ ] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [ ] **Localization:** All end-user-facing strings can be localized - [ ] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx ## Detailed Description of the Pull Request / Additional comments ## Validation Steps Performed --- .../Models/ExtensionService.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Models/ExtensionService.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Models/ExtensionService.cs index 6d59aa66b4..364d234f5e 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Models/ExtensionService.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Models/ExtensionService.cs @@ -2,6 +2,7 @@ // The Microsoft Corporation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using ManagedCommon; using Microsoft.CmdPal.Common.Services; using Microsoft.CommandPalette.Extensions; using Windows.ApplicationModel; @@ -287,9 +288,17 @@ public partial class ExtensionService : IExtensionService, IDisposable var installedExtensions = await GetInstalledExtensionsAsync(); foreach (var installedExtension in installedExtensions) { - if (installedExtension.IsRunning()) + Logger.LogDebug($"Signaling dispose to {installedExtension.ExtensionUniqueId}"); + try { - installedExtension.SignalDispose(); + if (installedExtension.IsRunning()) + { + installedExtension.SignalDispose(); + } + } + catch (Exception ex) + { + Logger.LogError($"Failed to send dispose signal to extension {installedExtension.ExtensionUniqueId}", ex); } } }