Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Sources/SemanticIndex/PreparationTaskDescription.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ package struct PreparationTaskDescription: IndexTaskDescription {
do {
try await buildSystemManager.prepare(targets: Set(targetsToPrepare))
} catch {
logger.error(
"Preparation failed: \(error.forLogging)"
)
logger.error("Preparation failed: \(error.forLogging)")
}
await hooks.preparationTaskDidFinish?(self)
if !Task.isCancelled {
Expand Down
8 changes: 8 additions & 0 deletions Sources/SemanticIndex/TaskScheduler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,14 @@ package actor QueuedTask<TaskDescription: TaskDescriptionProtocol> {
_isExecuting.value = true
executionTask = task
executionTaskCreatedContinuation.yield(task)
if self.resultTaskCancelled.value {
// The queued task might have been cancelled after the execution ask was started but before the task was yielded
// to `executionTaskCreatedContinuation`. In that case the result task will simply cancel the await on the
// `executionTaskCreatedStream` and hence not call `valuePropagatingCancellation` on the execution task. This
// means that the queued task cancellation wouldn't be propagated to the execution task. To address this, check if
// `resultTaskCancelled` was set and, if so, explicitly cancel the execution task here.
task.cancel()
}
await executionStateChangedCallback?(self, .executing)
return await task.value
}
Expand Down