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


##########
persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/internal/Running.scala:
##########
@@ -268,15 +288,43 @@ private[pekko] object Running {
         else Behaviors.unhandled
     }
 
-    def onCommand(state: RunningState[S], cmd: C): Behavior[InternalProtocol] 
= {
-      val effect = setup.commandHandler(state.state, cmd)
-      val (next, doUnstash) = applyEffects(cmd, state, 
effect.asInstanceOf[EffectImpl[E, S]]) // TODO can we avoid the cast?
-      if (doUnstash) tryUnstashOne(next)
-      else next
+    def onCommand(state: RunningState[S, C], cmd: C): 
Behavior[InternalProtocol] = {
+      def callApplyEffects(rs: RunningState[S, C], c: C) = {
+        val effect = setup.commandHandler(rs.state, c)
+
+        applyEffects(c, rs, effect.asInstanceOf[EffectImpl[E, S]]) // TODO can 
we avoid the cast?
+      }
+
+      var applyEffectsRetval: (Behavior[InternalProtocol], Boolean) = 
callApplyEffects(state, cmd)
+
+      var retVal: Option[Behavior[InternalProtocol]] = None
+
+      while (retVal.isEmpty) {

Review Comment:
   * is there any reason to worry about this loop spinning? - continuously 
trying unstash and getting empty returns
   * would it be worth considering some sort of backoff after we have tried 
unstash a few times and received empty values in each case?



-- 
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-unsubscr...@pekko.apache.org

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


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

Reply via email to