From e038b786a23d3fcd58998b5b902d95149833f15a Mon Sep 17 00:00:00 2001 From: Arnaud Date: Fri, 3 Apr 2026 10:38:43 +0400 Subject: [PATCH] Clean defaultChroniclesStream on close --- storage/storage.nim | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/storage/storage.nim b/storage/storage.nim index 16a2cb20..33a1a01c 100644 --- a/storage/storage.nim +++ b/storage/storage.nim @@ -131,6 +131,17 @@ proc close*(s: StorageServer) {.async.} = error "Failed to close Storage node", failures = res.failure.len raiseAssert "Failed to close Storage node" + proc noOutput(logLevel: LogLevel, msg: LogOutputStr) = + discard + + # If a log file was assigned, clear the `fileFlush` proc to ensure a clean + # state for future restarts. + # Without this manual cleanup, the old writer remains active in the global stream. + # When `setupLogging` is called again during a restart, the GC might trigger + # after the new context is created, destroying the newly assigned writer and + # leaving it silently capturing a `None` value. This results in missing log files. + defaultChroniclesStream.outputs[2].writer = noOutput + proc shutdown*(server: StorageServer) {.async.} = await server.stop() await server.close()