From 227372dcdfc1555bdb486cb6f9271cefb3e7027c Mon Sep 17 00:00:00 2001 From: Eoin Motherway <25342760+YuKitsune@users.noreply.github.com> Date: Sat, 17 Jan 2026 13:59:24 +1000 Subject: [PATCH 1/2] fix: Race condition when reporting errors to the user --- source/CPDLCPlugin/Plugin.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/source/CPDLCPlugin/Plugin.cs b/source/CPDLCPlugin/Plugin.cs index badd35e..cabd624 100644 --- a/source/CPDLCPlugin/Plugin.cs +++ b/source/CPDLCPlugin/Plugin.cs @@ -187,13 +187,16 @@ public static void AddError(Exception exception, string message) static void TryAddErrorInternal(Exception exception) { - // Don't flood the error window with the same message over and over again - if (ErrorMessages.TryGetValue(exception.Message, out var lastShown) && - DateTimeOffset.Now - lastShown <= TimeSpan.FromMinutes(1)) - return; + lock (ErrorMessages) + { + // Don't flood the error window with the same message over and over again + if (ErrorMessages.TryGetValue(exception.Message, out var lastShown) && + DateTimeOffset.Now - lastShown <= TimeSpan.FromMinutes(1)) + return; - Errors.Add(exception, Name); - ErrorMessages.Add(exception.Message, DateTimeOffset.Now); + Errors.Add(exception, Name); + ErrorMessages.Add(exception.Message, DateTimeOffset.Now); + } } void ConfigureTheme() From 8ebf83f8b4ab652e971a4a6119e359f3ca473556 Mon Sep 17 00:00:00 2001 From: Eoin Motherway <25342760+YuKitsune@users.noreply.github.com> Date: Sat, 17 Jan 2026 13:59:54 +1000 Subject: [PATCH 2/2] fix: Log before displaying to the user --- source/CPDLCPlugin/Plugin.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/CPDLCPlugin/Plugin.cs b/source/CPDLCPlugin/Plugin.cs index cabd624..04d7ef5 100644 --- a/source/CPDLCPlugin/Plugin.cs +++ b/source/CPDLCPlugin/Plugin.cs @@ -175,14 +175,14 @@ void NetworkDisconnected(object sender, EventArgs e) public static void AddError(Exception exception) { - TryAddErrorInternal(exception); Log.Error(exception, "An error has occurred"); + TryAddErrorInternal(exception); } public static void AddError(Exception exception, string message) { - TryAddErrorInternal(exception); Log.Error(exception, message); + TryAddErrorInternal(exception); } static void TryAddErrorInternal(Exception exception)