mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-03-13 03:16:46 +01:00
Fix: Plugin Exception Handler didn't disabled plugin if crash was detected
This commit is contained in:
parent
b2480ad081
commit
209f84e67b
1 changed files with 3 additions and 2 deletions
|
@ -33,18 +33,19 @@ namespace BTCPayServer.Plugins
|
||||||
!PluginManager.IsExceptionByPlugin(exception, out var pluginName))
|
!PluginManager.IsExceptionByPlugin(exception, out var pluginName))
|
||||||
return ValueTask.FromResult(false);
|
return ValueTask.FromResult(false);
|
||||||
_logs.Configuration.LogError(exception, $"Unhandled exception caused by plugin '{pluginName}', disabling it and restarting...");
|
_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());
|
_ = Task.Delay(3000).ContinueWith((t) => _applicationLifetime.StopApplication());
|
||||||
// Returning true here means we will see Error 500 error message.
|
// Returning true here means we will see Error 500 error message.
|
||||||
// Returning false means that the user will see a stacktrace.
|
// Returning false means that the user will see a stacktrace.
|
||||||
return ValueTask.FromResult(false);
|
return ValueTask.FromResult(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static bool GetDisablePluginIfCrash(HttpContext httpContext)
|
public static bool GetDisablePluginIfCrash(HttpContext httpContext)
|
||||||
{
|
{
|
||||||
return httpContext.Items.TryGetValue("DisablePluginIfCrash", out object renderingDashboard) ||
|
return httpContext.Items.TryGetValue("DisablePluginIfCrash", out object renderingDashboard) ||
|
||||||
renderingDashboard is not true;
|
renderingDashboard is not true;
|
||||||
}
|
}
|
||||||
internal static void SetDisablePluginIfCrash(HttpContext httpContext)
|
public static void SetDisablePluginIfCrash(HttpContext httpContext)
|
||||||
{
|
{
|
||||||
httpContext.Items.TryAdd("DisablePluginIfCrash", true);
|
httpContext.Items.TryAdd("DisablePluginIfCrash", true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue