Files
sourcekit-lsp/Sources/SKTestSupport/SourceKitD+send.swift
Alex Hoppen 14cfd50582 If sourcekitd or clangd don’t respond to a request for 5 minutes, terminate them and use crash recovery to restore behavior
This should be a last stop-gap measure in case sourcekitd or clangd get stuck, don’t respond to any requests anymore and don’t honor cancellation either. In that case we can restore SourceKit-LSP behavior by killing them and using the crash recovery logic to restore functionality.

rdar://149492159
2025-05-07 13:43:28 +02:00

30 lines
1006 B
Swift

//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
package import SourceKitD
extension SourceKitD {
/// Convenience overload of the `send` function for testing that doesn't restart sourcekitd if it does not respond
/// and doesn't pass any file contents.
package func send(
_ request: SKDRequestDictionary,
timeout: Duration
) async throws -> SKDResponseDictionary {
return try await self.send(
request,
timeout: timeout,
restartTimeout: .seconds(60 * 60 * 24),
fileContents: nil
)
}
}