Swift Task.sleep timeout race condition in iOS 15 and iOS 16
Developers want to guarantee that a timeout set with Task.sleep stops any further work as soon as the cancellation signal is received, preventing unnecessary execution after the deadline. The common approach of racing Task.sleep against a task and checking Task.isCancelled after the sleep finishes creates a race window: the task may observe cancellation only