Description
Describe the bug
try await Task.sleep(nanoseconds: .max)
returns immediately (without error). I would expect the task to be suspended for UInt.max
nanoseconds.
To Reproduce
Swift playground to reproduce the behavior:
import Foundation
import _Concurrency
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
Task.detached {
try! await Task.sleep(nanoseconds: .max)
}
Expected behavior
The task should suspend for UInt64.max
nanoseconds.
Screenshots
N/A
Environment (please complete the following information):
- OS: [e.g. macOS 11.0] 12.3.1 (21E258)
- Xcode Version/Tag/Branch: Version 13.3 (13E113)
Additional context
I'm trying to suspend a task indefinitely within some tests to check cancellation within a larger component works as expected.
Setting nanoseconds
parameter to 5 * 1_000_000_000
suspends for 5 seconds as expected.
My current workaround is to set nanoseconds
to a sufficiently large value that works within the context of my tests (e.g. suspending for 30s is plenty for this situation)