4 Commits
Author SHA1 Message Date
Joseph CursioandClaude Opus 5.5 963eecf5ee Skip the write in DuplexAsyncChannel.Writer.finish when the buffer is empty (#476)
* Skip the write in DuplexAsyncChannel.Writer.finish when the buffer is empty

A cloned writer's finish(buffer:finalElement:) always called
write(buffer:), even with an empty buffer. Once another clone had
finished the channel, that write threw
MultiProducerSingleConsumerAsyncChannelAlreadyFinishedError, so a
second `try await finish()` failed although it had nothing to write.
This is why clonedWriterCanProduceConcurrently has failed since #459.

Only write when the buffer has elements. A clone that still has
buffered elements after the channel finished keeps throwing.

Resolves #470.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Test finishing a cloned writer through the protocol and the adapter

clonedWriterCanProduceConcurrently only covers a direct
`try await clone.finish()`. Also cover a generic CallerAsyncWriter and
asAsyncWriter(), where there is no concrete finish() overload, after
the other writer has finished. Both threw
MultiProducerSingleConsumerAsyncChannelAlreadyFinishedError before the
previous commit.

A third test checks that finishing a clone with elements still throws
once the channel has finished, so those elements are never dropped
silently.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 12:46:09 +01:00
Francesco Paolo Severino 13713a4ffd Fix compilation errors in AsyncStreaming (#459)
* Fix compilation errors

* Enable traits in CI
2026-09-29 13:33:55 +02:00
Franz Busch e81438119c [AsyncStreaming] Skip empty buffers in AsyncReader.forEachBuffer (#435)
When a reader signals end-of-stream with an empty buffer, body was still invoked with that empty buffer. Skip the body call when the buffer is empty.
2026-06-23 10:48:22 +02:00
David SmithandFranz Busch 8ee3d2be19 "[AsyncStreaming] Introduce a MultiProducerSingleConsumerChannel and a duplex" + a build fix (#428)
* [AsyncStreaming] Introduce a `MultiProducerSingleConsumerChannel` and a duplex

* Add tests

* Fix UnstableAsyncStreaming test build

---------

Co-authored-by: Franz Busch <f.busch@apple.com>
2026-06-05 17:15:19 -07:00