Open saguiitay opened 4 months ago
The current design of the middleware pipeline doesn't really help with exception handling, as you've noticed. It's very low-level and assumes knowledge of how the dispatcher works. I think we'd need some enhancements or redesigns to create a more developer-friendly experience for middleware.
Thanks for the update. Is my suggested solution technically correct? Should I go that way until the team come up with a better design? Is that in the near-future roadmap?
Gentle ping regarding these questions:
Is my suggested solution technically correct? Should I go that way until the team come up with a better design?
Is my suggested solution technically correct?
Yes, this is correct. As a reference, you can see what we're doing with this middleware in the Durable Functions extension here.
Should I go that way until the team come up with a better design?
We don't have any alternatives, and we ourselves rely on this pretty heavily (and thus won't break it) so I'd say it's safe to go this route for now.
Is that in the near-future roadmap?
This is not on our roadmap, unfortunately. However, we'd be willing to accept it as a contribution since it seems like a generally useful feature.
I've created a middleware to centrally handle various types of exceptions. Before my change, I had a try-catch block in my
TaskActivity.Execute()
method:This worked fine regarding retries when an exception is thrown. However, when I moved this logic to a middleware, RetryOptions were disregarded, and the same activity was retried over-and-over indefinitely:
Is there some guidance on handling exceptions in middleware? Is there a correct way to handle this scenario? I've tried simulating the behavior of the dispatcher, and managed to get this to work, but that feels incorrect:
@cgillum @davidmrdavid