From f7ab6c5e715e1d62235cd6b4d67da14797847f09 Mon Sep 17 00:00:00 2001 From: Alex Hoppen Date: Mon, 20 Jan 2025 19:54:50 -0800 Subject: [PATCH] Flush the `NonDarwinLogger` before shutting down `SourceKitLSPServer` This ensures that we don't drop any log messages when stopping the LSP server, in particular while running tests. --- Sources/SourceKitLSP/SourceKitLSPServer.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sources/SourceKitLSP/SourceKitLSPServer.swift b/Sources/SourceKitLSP/SourceKitLSPServer.swift index 05ae24aaf..d7db1ee1f 100644 --- a/Sources/SourceKitLSP/SourceKitLSPServer.swift +++ b/Sources/SourceKitLSP/SourceKitLSPServer.swift @@ -1158,6 +1158,8 @@ extension SourceKitLSPServer { await workspace.buildSystemManager.setMainFilesProvider(nil) workspace.closeIndex() } + // Make sure we emit all pending log messages. When we're not using `NonDarwinLogger` this is a no-op. + await NonDarwinLogger.flush() } func shutdown(_ request: ShutdownRequest) async throws -> ShutdownRequest.Response {