From 59f3eeecf22680bc0932ee2e30eea75f890e4236 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Thu, 16 May 2024 22:21:35 -0500 Subject: [PATCH 1/5] add a close overload for jsonrpcpluginv2 --- Flow.Launcher.Core/Plugin/JsonRPCPluginV2.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher.Core/Plugin/JsonRPCPluginV2.cs b/Flow.Launcher.Core/Plugin/JsonRPCPluginV2.cs index 46c72624a..9b094e315 100644 --- a/Flow.Launcher.Core/Plugin/JsonRPCPluginV2.cs +++ b/Flow.Launcher.Core/Plugin/JsonRPCPluginV2.cs @@ -139,11 +139,11 @@ namespace Flow.Launcher.Core.Plugin return Task.CompletedTask; } - public virtual ValueTask DisposeAsync() + public virtual async ValueTask DisposeAsync() { + await RPC.InvokeAsync("close"); RPC?.Dispose(); ErrorStream?.Dispose(); - return ValueTask.CompletedTask; } } } From cea1fcfe47229848df6ed694108cf0a158cae4a6 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Thu, 16 May 2024 22:24:24 -0500 Subject: [PATCH 2/5] skip if method not found --- Flow.Launcher.Core/Plugin/JsonRPCPluginV2.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Flow.Launcher.Core/Plugin/JsonRPCPluginV2.cs b/Flow.Launcher.Core/Plugin/JsonRPCPluginV2.cs index 9b094e315..8eb5c4459 100644 --- a/Flow.Launcher.Core/Plugin/JsonRPCPluginV2.cs +++ b/Flow.Launcher.Core/Plugin/JsonRPCPluginV2.cs @@ -5,6 +5,7 @@ using System.IO.Pipelines; using System.Threading; using System.Threading.Tasks; using Flow.Launcher.Core.Plugin.JsonRPCV2Models; +using Flow.Launcher.Infrastructure.Logger; using Flow.Launcher.Plugin; using Microsoft.VisualStudio.Threading; using StreamJsonRpc; @@ -141,7 +142,20 @@ namespace Flow.Launcher.Core.Plugin public virtual async ValueTask DisposeAsync() { - await RPC.InvokeAsync("close"); + try + { + await RPC.InvokeAsync("close"); + } + catch (RemoteMethodNotFoundException e) + { + } + catch (Exception e) + { + Log.Exception( + $"Exception when calling close method for plugin <{Context.CurrentPluginMetadata.Name}>", + e); + } + RPC?.Dispose(); ErrorStream?.Dispose(); } From f54c92402b6340bca4a434b5dbb2b9163c06ec8b Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Thu, 23 May 2024 12:54:03 -0500 Subject: [PATCH 3/5] rethrow instead of catching general exception --- Flow.Launcher.Core/Plugin/JsonRPCPluginV2.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Flow.Launcher.Core/Plugin/JsonRPCPluginV2.cs b/Flow.Launcher.Core/Plugin/JsonRPCPluginV2.cs index 8eb5c4459..933b549c7 100644 --- a/Flow.Launcher.Core/Plugin/JsonRPCPluginV2.cs +++ b/Flow.Launcher.Core/Plugin/JsonRPCPluginV2.cs @@ -149,12 +149,6 @@ namespace Flow.Launcher.Core.Plugin catch (RemoteMethodNotFoundException e) { } - catch (Exception e) - { - Log.Exception( - $"Exception when calling close method for plugin <{Context.CurrentPluginMetadata.Name}>", - e); - } RPC?.Dispose(); ErrorStream?.Dispose(); From 81f234e230c6312f672b821bc2f8c812452098b1 Mon Sep 17 00:00:00 2001 From: Kevin Zhang <45326534+taooceros@users.noreply.github.com> Date: Sun, 26 May 2024 23:00:11 -0700 Subject: [PATCH 4/5] Remove unused using; --- Flow.Launcher.Core/Plugin/JsonRPCPluginV2.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Flow.Launcher.Core/Plugin/JsonRPCPluginV2.cs b/Flow.Launcher.Core/Plugin/JsonRPCPluginV2.cs index 933b549c7..37e0961eb 100644 --- a/Flow.Launcher.Core/Plugin/JsonRPCPluginV2.cs +++ b/Flow.Launcher.Core/Plugin/JsonRPCPluginV2.cs @@ -5,7 +5,6 @@ using System.IO.Pipelines; using System.Threading; using System.Threading.Tasks; using Flow.Launcher.Core.Plugin.JsonRPCV2Models; -using Flow.Launcher.Infrastructure.Logger; using Flow.Launcher.Plugin; using Microsoft.VisualStudio.Threading; using StreamJsonRpc; From b4a33479c686718d82f6eff094390be392957e15 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Mon, 27 May 2024 01:15:00 -0500 Subject: [PATCH 5/5] dispose other stuff in finally block --- Flow.Launcher.Core/Plugin/JsonRPCPluginV2.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Flow.Launcher.Core/Plugin/JsonRPCPluginV2.cs b/Flow.Launcher.Core/Plugin/JsonRPCPluginV2.cs index 37e0961eb..5a6633525 100644 --- a/Flow.Launcher.Core/Plugin/JsonRPCPluginV2.cs +++ b/Flow.Launcher.Core/Plugin/JsonRPCPluginV2.cs @@ -148,9 +148,11 @@ namespace Flow.Launcher.Core.Plugin catch (RemoteMethodNotFoundException e) { } - - RPC?.Dispose(); - ErrorStream?.Dispose(); + finally + { + RPC?.Dispose(); + ErrorStream?.Dispose(); + } } } }