Did you check if UInt64(total - id) * 1_000_000_000
statement overflows?
If so you could try something like this: let (value, overflowOccurred) = interval.multipliedReportingOverflow(by: 1_000_000_000)
and then check overflowOccurred
value
I've tried try await Task.sleep(nanoseconds: Int64.max)
and it completes immediately. At the same time documentation doesn't state which max value could be passed to this method.