Missing Cancellation Check (ARCH9024)
Key swift.async.missing-cancellation-check · Severity warning · Category async
Flags long loops in async functions that never check Task.isCancelled / Task.checkCancellation() - cancellation cannot stop them.
Incorrect
Section titled “Incorrect”for item in items { await process(item) }Correct
Section titled “Correct”for item in items { try Task.checkCancellation(); await process(item) }Check Task.isCancelled or call Task.checkCancellation() inside the loop.