pjfanning commented on code in PR #3024:
URL: https://github.com/apache/pekko/pull/3024#discussion_r3330790984


##########
stream/src/main/scala/org/apache/pekko/stream/Attributes.scala:
##########
@@ -565,6 +565,44 @@ object Attributes {
      */
     @ApiMayChange
     def afterDelay(delay: java.time.Duration, strategy: Strategy): Strategy = 
AfterDelay(delay.toScala, strategy)
+
+    /**
+     * Strategy that ensures graceful shutdown for bidirectional components.
+     *
+     * When `cancelStage` is invoked, this strategy first completes all output 
ports (regularly or with an error),
+     * then waits for a grace period to allow the completion/error signal to 
propagate through the counterpart,
+     * and finally cancels all input ports.
+     *
+     * This addresses the race condition in bidirectional components where 
cancelling the upstream side might
+     * prevent the error from being properly propagated downstream. By 
completing outputs first and waiting,
+     * the error has a chance to bubble through the counterpart before the 
upstream is cancelled.
+     *
+     * This strategy is particularly useful in stacks of BidiFlows where 
different layers are connected
+     * through both inputs and outputs, and error propagation is important for 
proper diagnostics.
+     *
+     * @param delay the grace period to wait after completing outputs before 
cancelling inputs
+     */

Review Comment:
   `@since 2.0.0`



-- 
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]

Reply via email to