From b463d82ca5313d915b0a46022e945ee872b8db0d Mon Sep 17 00:00:00 2001 From: Nikolche Kolev Date: Wed, 25 Sep 2019 15:58:13 -0700 Subject: [PATCH 1/2] plugin manager plugin initialization is not cancellable --- src/NuGet.Core/NuGet.Protocol/Plugins/PluginManager.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/NuGet.Core/NuGet.Protocol/Plugins/PluginManager.cs b/src/NuGet.Core/NuGet.Protocol/Plugins/PluginManager.cs index 8b85f899e33..4ed751398bf 100644 --- a/src/NuGet.Core/NuGet.Protocol/Plugins/PluginManager.cs +++ b/src/NuGet.Core/NuGet.Protocol/Plugins/PluginManager.cs @@ -194,6 +194,8 @@ private async Task> TryCreatePluginAsync( JObject serviceIndex, CancellationToken cancellationToken) { + // This is a non cancellable task. + cancellationToken = CancellationToken.None; PluginCreationResult pluginCreationResult = null; var cacheEntry = new PluginCacheEntry(_pluginsCacheDirectoryPath.Value, result.PluginFile.Path, requestKey.PackageSourceRepository); From 498fb709d3a004320fede81127c943ce766ccca1 Mon Sep 17 00:00:00 2001 From: Nikolche Kolev Date: Mon, 30 Sep 2019 23:52:07 -0700 Subject: [PATCH 2/2] Update PluginManager.cs --- src/NuGet.Core/NuGet.Protocol/Plugins/PluginManager.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/NuGet.Core/NuGet.Protocol/Plugins/PluginManager.cs b/src/NuGet.Core/NuGet.Protocol/Plugins/PluginManager.cs index 4ed751398bf..11ec4cfe842 100644 --- a/src/NuGet.Core/NuGet.Protocol/Plugins/PluginManager.cs +++ b/src/NuGet.Core/NuGet.Protocol/Plugins/PluginManager.cs @@ -195,6 +195,12 @@ private async Task> TryCreatePluginAsync( CancellationToken cancellationToken) { // This is a non cancellable task. + // We should only honor cancellation requests we can recover from. + // Once we have reached this part of the code, we do the plugin initialization + // handshake, operation claims, and shut down set up. + // If either one of these tasks fails then the plugin itself is not usable for the rest of the process. + // We could consider handling each of this operations more cleverly, + // but simplicity and readability is prioritized cancellationToken = CancellationToken.None; PluginCreationResult pluginCreationResult = null; var cacheEntry = new PluginCacheEntry(_pluginsCacheDirectoryPath.Value, result.PluginFile.Path, requestKey.PackageSourceRepository);