You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@pekko.apache.org by "He-Pin (via GitHub)" <gi...@apache.org> on 2026/06/20 12:05:30 UTC

[I] Throttle stage lacks supervisor strategy support for costCalculation exceptions [pekko]

He-Pin opened a new issue, #3101:
URL: https://github.com/apache/pekko/issues/3101

   ### Motivation
   
   The `Throttle` stage's `costCalculation` function is called without any exception handling. If the user-provided cost function throws, the exception propagates directly and fails the stage unconditionally. Unlike other stages (e.g., `MapAsync`, `Log`, `Filter`), Throttle does not consult the `SupervisionStrategy` decider, preventing users from configuring Resume or Restart behavior for bad elements.
   
   ### Current behavior
   
   In `Throttle.scala:71-84`, `costCalculation(elem)` is called without try-catch:
   
   ```scala
   override def onPush(): Unit = {
     val elem = grab(in)
     val cost = costCalculation(elem)  // No error handling
     val delayNanos = tokenBucket.offer(cost)
     ...
   }
   ```
   
   ### Proposed fix
   
   1. Add `lazy val decider = inheritedAttributes.mandatoryAttribute[SupervisionStrategy].decider` in `createLogic`
   2. Mix in `StageLogging` trait for error logging
   3. Wrap `costCalculation(elem)` in try-catch, consult decider on exception:
      - `Stop` → `failStage(ex)` (current behavior)
      - `Resume`/`Restart` → log error and `pull(in)` to skip the element
   4. Add tests verifying supervision directives work with Throttle
   
   ### References
   
   - Inspired by Akka.NET [#6886](https://github.com/akkadotnet/akka.net/pull/6886)
   - Similar pattern exists in Pekko's `MapAsync` (`Ops.scala:1301`) and `Log` (`Ops.scala:1542`)


-- 
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: notifications-unsubscribe@pekko.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [I] Throttle stage lacks supervisor strategy support for costCalculation exceptions [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin closed issue #3101: Throttle stage lacks supervisor strategy support for costCalculation exceptions
URL: https://github.com/apache/pekko/issues/3101


-- 
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: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [I] Throttle stage lacks supervisor strategy support for costCalculation exceptions [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin closed issue #3101: Throttle stage lacks supervisor strategy support for costCalculation exceptions
URL: https://github.com/apache/pekko/issues/3101


-- 
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: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org