diff --git a/Sources/NIOCore/AsyncChannel/AsyncChannel.swift b/Sources/NIOCore/AsyncChannel/AsyncChannel.swift index 74fdd53dcb..105862576d 100644 --- a/Sources/NIOCore/AsyncChannel/AsyncChannel.swift +++ b/Sources/NIOCore/AsyncChannel/AsyncChannel.swift @@ -305,8 +305,20 @@ public struct NIOAsyncChannel: Sendable { // We ignore errors from close, since all we care about is that the channel has been closed // at this point. self.channel.close(promise: nil) - // `closeFuture` is never failed, so we can ignore the error - try? await self.channel.closeFuture.get() + // `closeFuture` should never be failed, so we could ignore the error. However, do an + // assertionFailure to guide bad Channel implementations that are incorrectly failing this + // future to stop failing it. + do { + try await self.channel.closeFuture.get() + } catch { + assertionFailure( + """ + The channel's closeFuture should never be failed, but it was failed with error: \(error). + This is an error in the channel's implementation. + Refer to `Channel/closeFuture`'s documentation for more information. + """ + ) + } return result }