From e59df13bb01255e033e057cf6d022d2e30ca8bf0 Mon Sep 17 00:00:00 2001 From: Alex Hoppen Date: Thu, 2 Jan 2025 13:23:18 +0100 Subject: [PATCH] Clear `inProgressTextDocumentRequests` on `textDocumentTrackingQueue` `inProgressTextDocumentRequests` is supposed to only be accessed on `textDocumentTrackingQueue` but we were accessing it outside of that queue. Because of this, we might try to remove requests from `inProgressTextDocumentRequests` before adding them, which would cause them to stay in the list indefinitely. --- Sources/SourceKitLSP/SourceKitLSPServer.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/SourceKitLSP/SourceKitLSPServer.swift b/Sources/SourceKitLSP/SourceKitLSPServer.swift index 323d6fb1..997df9d3 100644 --- a/Sources/SourceKitLSP/SourceKitLSPServer.swift +++ b/Sources/SourceKitLSP/SourceKitLSPServer.swift @@ -654,7 +654,9 @@ extension SourceKitLSPServer: QueueBasedMessageHandler { ) async { defer { if let request = params as? any TextDocumentRequest { - self.inProgressTextDocumentRequests[request.textDocument.uri, default: []].removeAll { $0.id == id } + textDocumentTrackingQueue.async(priority: .background) { + self.inProgressTextDocumentRequests[request.textDocument.uri, default: []].removeAll { $0.id == id } + } } }