He-Pin opened a new issue, #3104:
URL: https://github.com/apache/pekko/issues/3104
### Motivation
`alsoTo` uses `Broadcast[Out](2, eagerCancel = true)` internally. When the
side sink fails or cancels, the entire stream is terminated. Users cannot
isolate the side sink — for example, a fire-and-forget logging sink should not
kill the main business stream when the logging destination is temporarily
unavailable.
### Current behavior
`Flow.scala:4014-4020`:
```scala
protected def alsoToGraph[M](that: Graph[SinkShape[Out], M]):
Graph[FlowShape[Out @uncheckedVariance, Out], M] =
GraphDSL.createGraph(that) { implicit b => r =>
import GraphDSL.Implicits._
val bcast = b.add(Broadcast[Out](2, eagerCancel = true))
bcast.out(1) ~> r
FlowShape(bcast.in, bcast.out(0))
}
```
With `eagerCancel = true`, any cancellation from the side sink immediately
cancels the entire stream.
### Proposed fix
1. Add a new `alsoTo` overload accepting `propagateCancellation: Boolean =
true`
2. When `propagateCancellation = false`, use a custom GraphStage that:
- Forwards elements to both the main downstream and the side sink
- When the side sink cancels/fails, logs a warning and continues
forwarding to main downstream only
- When the main downstream cancels, cancels the side sink normally
3. Update both Scala and Java DSLs
4. Add tests for both propagation modes
### References
- Inspired by Akka.NET
[#7301](https://github.com/akkadotnet/akka.net/pull/7301)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]