From 209f84e67ba59ff30560223f67040c1ab6f646e0 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Wed, 17 Jul 2024 11:23:14 +0900 Subject: [PATCH] Fix: Plugin Exception Handler didn't disabled plugin if crash was detected --- BTCPayServer/Plugins/PluginExceptionHandler.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/BTCPayServer/Plugins/PluginExceptionHandler.cs b/BTCPayServer/Plugins/PluginExceptionHandler.cs index 93cd049c7..194d79ec8 100644 --- a/BTCPayServer/Plugins/PluginExceptionHandler.cs +++ b/BTCPayServer/Plugins/PluginExceptionHandler.cs @@ -33,18 +33,19 @@ namespace BTCPayServer.Plugins !PluginManager.IsExceptionByPlugin(exception, out var pluginName)) return ValueTask.FromResult(false); _logs.Configuration.LogError(exception, $"Unhandled exception caused by plugin '{pluginName}', disabling it and restarting..."); + PluginManager.DisablePlugin(_pluginDir, pluginName); _ = Task.Delay(3000).ContinueWith((t) => _applicationLifetime.StopApplication()); // Returning true here means we will see Error 500 error message. // Returning false means that the user will see a stacktrace. return ValueTask.FromResult(false); } - internal static bool GetDisablePluginIfCrash(HttpContext httpContext) + public static bool GetDisablePluginIfCrash(HttpContext httpContext) { return httpContext.Items.TryGetValue("DisablePluginIfCrash", out object renderingDashboard) || renderingDashboard is not true; } - internal static void SetDisablePluginIfCrash(HttpContext httpContext) + public static void SetDisablePluginIfCrash(HttpContext httpContext) { httpContext.Items.TryAdd("DisablePluginIfCrash", true); }