From c68a9892fe9b579ef39ec293bf963e77704e480d Mon Sep 17 00:00:00 2001 From: Alex Hoppen Date: Mon, 10 Mar 2025 15:24:30 -0700 Subject: [PATCH] Log sourcekitd requests inside `withCancellableCheckedThrowingContinuation` Otherwise, we would log sending the sourcekitd request even if the task was already cancelled and we thus took an early exit in `withCancellableCheckedThrowingContinuation`. --- Sources/SourceKitD/SourceKitD.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sources/SourceKitD/SourceKitD.swift b/Sources/SourceKitD/SourceKitD.swift index 331414bc..ca7dd07e 100644 --- a/Sources/SourceKitD/SourceKitD.swift +++ b/Sources/SourceKitD/SourceKitD.swift @@ -139,10 +139,9 @@ extension SourceKitD { timeout: Duration, fileContents: String? ) async throws -> SKDResponseDictionary { - log(request: request) - let sourcekitdResponse = try await withTimeout(timeout) { return try await withCancellableCheckedThrowingContinuation { (continuation) -> SourceKitDRequestHandle? in + self.log(request: request) var handle: sourcekitd_api_request_handle_t? = nil self.api.send_request(request.dict, &handle) { response in continuation.resume(returning: SKDResponse(response!, sourcekitd: self))