Skip to content

Commit 3788a45

Browse files
committed
Add log messages to track target preparation
These should help us figure out the root cause of rdar://129698768 if we hit it again.
1 parent 518aac4 commit 3788a45

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

Sources/SemanticIndex/SemanticIndexManager.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,10 @@ public final actor SemanticIndexManager {
411411
await self.prepare(targets: [target], priority: nil)
412412
}
413413
}
414-
inProgressPrepareForEditorTask?.task.cancel()
414+
if let inProgressPrepareForEditorTask {
415+
logger.debug("Cancelling preparation of \(inProgressPrepareForEditorTask.document) because \(uri) was opened")
416+
inProgressPrepareForEditorTask.task.cancel()
417+
}
415418
inProgressPrepareForEditorTask = InProgressPrepareForEditorTask(
416419
id: id,
417420
document: uri,

Tests/SourceKitLSPTests/ExpectedIndexTaskTracker.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
import LSPLogging
1314
import LanguageServerProtocol
1415
import SKCore
1516
import SemanticIndex
@@ -103,6 +104,7 @@ actor ExpectedIndexTaskTracker {
103104
return
104105
}
105106
if Task.isCancelled {
107+
logger.debug("Ignoring preparation task start because task is cancelled: \(taskDescription.targetsToPrepare)")
106108
return
107109
}
108110
guard let expectedTargetsToPrepare = expectedPreparations.first else {
@@ -120,6 +122,7 @@ actor ExpectedIndexTaskTracker {
120122
return
121123
}
122124
if Task.isCancelled {
125+
logger.debug("Ignoring preparation task finish because task is cancelled: \(taskDescription.targetsToPrepare)")
123126
return
124127
}
125128
guard let expectedTargetsToPrepare = expectedPreparations.first else {
@@ -147,6 +150,12 @@ actor ExpectedIndexTaskTracker {
147150

148151
func updateIndexStoreTaskDidStart(taskDescription: UpdateIndexStoreTaskDescription) -> Void {
149152
if Task.isCancelled {
153+
logger.debug(
154+
"""
155+
Ignoring update indexstore start because task is cancelled: \
156+
\(taskDescription.filesToIndex.map(\.file.sourceFile))
157+
"""
158+
)
150159
return
151160
}
152161
guard let expectedFilesToIndex = expectedIndexStoreUpdates?.first else {
@@ -165,6 +174,12 @@ actor ExpectedIndexTaskTracker {
165174
return
166175
}
167176
if Task.isCancelled {
177+
logger.debug(
178+
"""
179+
Ignoring update indexstore finish because task is cancelled: \
180+
\(taskDescription.filesToIndex.map(\.file.sourceFile))
181+
"""
182+
)
168183
return
169184
}
170185
guard let expectedFilesToIndex = expectedIndexStoreUpdates.first else {

0 commit comments

Comments
 (0)