@@ -29,8 +29,8 @@ import struct Foundation.Data
2929 public nonisolated let logger : Logger
3030
3131 private var isConnected = false
32- private let messageStream : AsyncStream < Data >
33- private let messageContinuation : AsyncStream < Data > . Continuation
32+ private let messageStream : AsyncThrowingStream < Data , Swift . Error >
33+ private let messageContinuation : AsyncThrowingStream < Data , Swift . Error > . Continuation
3434
3535 public init (
3636 input: FileDescriptor = FileDescriptor . standardInput,
@@ -46,8 +46,8 @@ import struct Foundation.Data
4646 factory: { _ in SwiftLogNoOpLogHandler ( ) } )
4747
4848 // Create message stream
49- var continuation : AsyncStream < Data > . Continuation !
50- self . messageStream = AsyncStream { continuation = $0 }
49+ var continuation : AsyncThrowingStream < Data , Swift . Error > . Continuation !
50+ self . messageStream = AsyncThrowingStream { continuation = $0 }
5151 self . messageContinuation = continuation
5252 }
5353
@@ -177,14 +177,7 @@ import struct Foundation.Data
177177 /// or batches containing multiple requests/notifications encoded as JSON arrays.
178178 /// Each message is guaranteed to be a complete JSON object or array.
179179 public func receive( ) -> AsyncThrowingStream < Data , Swift . Error > {
180- return AsyncThrowingStream { continuation in
181- Task {
182- for await message in messageStream {
183- continuation. yield ( message)
184- }
185- continuation. finish ( )
186- }
187- }
180+ return messageStream
188181 }
189182 }
190183#endif
0 commit comments