![]() ### Motivation: Follow up PR for https://github.com/apple/swift-nio/pull/2399 We currently still return `nil` if the current `Task` is canceled before the first call to `NIOThrowingAsyncSequenceProducer.AsyncIterator.next()` but it should throw `CancellationError` too. In addition, the generic `Failure` type turns out to be a problem. Just throwing a `CancellationError` without checking that `Failure` type is `any Swift.Error` or `CancellationError` introduced a type safety violation as we throw an unrelated type. ### Modifications: - throw `CancellationError` on eager cancellation - deprecates the generic `Failure` type of `NIOThrowingAsyncSequenceProducer`. It now must always be `any Swift.Error`. For backward compatibility we will still return nil if `Failure` is not `any Swift.Error` or `CancellationError`. ### Result: `CancellationError` is now correctly thrown instead of returning `nil` on eager cancelation. Generic `Failure` type is deprecated. |
||
---|---|---|
.. | ||
NIOAsyncSequenceProducer+HighLowWatermarkBackPressureStrategyTests.swift | ||
NIOAsyncSequenceTests.swift | ||
NIOAsyncWriterTests.swift | ||
NIOThrowingAsyncSequenceTests.swift |