Skip to content

Commit 70342c9

Browse files
authored
Fix race in 'executeOperation(props:operation)' (#9)
If the task got cancelled while still waiting for dependencies, 'completePendingTask(with:)' was not executed, leaving a zombie in the queue.
1 parent 29ddd86 commit 70342c9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Sources/Queue/AsyncQueue.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,14 @@ public final class AsyncQueue: @unchecked Sendable {
118118
props: ExecutionProperties,
119119
@_inheritActorContext operation: @escaping ThrowingOperation<Success>
120120
) async rethrows -> Success {
121-
for awaitable in props.dependencies {
122-
await awaitable.waitForCompletion()
123-
}
124-
125121
defer {
126122
completePendingTask(with: props)
127123
}
128124

125+
for awaitable in props.dependencies {
126+
await awaitable.waitForCompletion()
127+
}
128+
129129
do {
130130
return try await operation()
131131
} catch is CancellationError {

0 commit comments

Comments
 (0)