From 9cced198f98abf3a2fdce4c8738ddc00a352e3d3 Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Wed, 15 Jul 2026 22:18:15 -0700 Subject: [PATCH] fix(console): restore pump error logging; drop unused Stop; stop invalidating help cache on lookup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ConsoleInputPump gains an optional ILogger so the reader-fault and command-dispatch catch blocks log warnings/errors again, matching the behavior the old ConsoleInputHandler had before the pump refactor. - Remove ConsoleInputPump.Stop() — dead code, nothing calls it; the reader thread already terminates on EOF/Core.Closing/finally cleanup. - GetInputCommand no longer clears the help-description cache on every lookup; RegisterCommand/UnregisterInputCommand still invalidate it correctly on the paths that actually change the command set. --- Projects/Server/Console/ConsoleInputHandler.cs | 3 +-- Projects/Server/Console/ConsoleInputPump.cs | 16 +++++++--------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Projects/Server/Console/ConsoleInputHandler.cs b/Projects/Server/Console/ConsoleInputHandler.cs index 0347a6524..0cd091110 100644 --- a/Projects/Server/Console/ConsoleInputHandler.cs +++ b/Projects/Server/Console/ConsoleInputHandler.cs @@ -69,7 +69,6 @@ public static class ConsoleInputHandler lock (_inputCommands) { var action = _inputCommands.GetValueOrDefault(command)?.Function; - _commandDescriptions = null; return action; } } @@ -88,7 +87,7 @@ public static class ConsoleInputHandler return; } - _pump = new ConsoleInputPump(Console.In, GetInputCommand); + _pump = new ConsoleInputPump(Console.In, GetInputCommand, logger); new Thread(_pump.Run) { diff --git a/Projects/Server/Console/ConsoleInputPump.cs b/Projects/Server/Console/ConsoleInputPump.cs index eb40f60b0..e6ce1e339 100644 --- a/Projects/Server/Console/ConsoleInputPump.cs +++ b/Projects/Server/Console/ConsoleInputPump.cs @@ -1,6 +1,7 @@ using System; using System.IO; using System.Threading; +using Server.Logging; namespace Server; @@ -17,6 +18,7 @@ internal sealed class ConsoleInputPump { private readonly TextReader _input; private readonly Func> _lookup; + private readonly Server.Logging.ILogger _logger; private readonly object _gate = new(); private readonly AutoResetEvent _promptDelivered = new(false); @@ -24,20 +26,15 @@ internal sealed class ConsoleInputPump private string _promptResult; private volatile bool _running = true; - public ConsoleInputPump(TextReader input, Func> lookup) + public ConsoleInputPump(TextReader input, Func> lookup, Server.Logging.ILogger logger = null) { _input = input ?? throw new ArgumentNullException(nameof(input)); _lookup = lookup ?? throw new ArgumentNullException(nameof(lookup)); + _logger = logger; } public bool Running => _running; - public void Stop() - { - _running = false; - ReleasePendingPrompt(null); - } - public void Run() { try @@ -51,6 +48,7 @@ internal sealed class ConsoleInputPump } catch { + _logger?.Warning("Console commands have been disabled due to an error."); break; } @@ -93,9 +91,9 @@ internal sealed class ConsoleInputPump var action = _lookup(split[0].ToLower()); action?.Invoke(split.Length > 1 ? split[1] : string.Empty); } - catch + catch (Exception e) { - // A throwing lookup or handler logs its own failures; never let one kill the loop. + _logger?.Error(e, "Failed to execute console command: {Command}", line); } } }