[Feature Request] Optionally notify observers only
mvastola opened this issue · 4 comments
Is there any way to configure this middleware to not terminate the request or raise an exception, but to just trigger an observer callback? (If not, can there be?)
In my case I just want to run code to perform diagnostics/logging on a request if it takes too long.
You could write a middleware that inserts its self right before this one that catches the exception and the swallows it (instead of re-raising). Then you could do whatever you wanted with that info.
@schneems would that work? The point is I still want the request to finish no matter how long it takes.
IDK, try it
I was trying to hint it wouldn't, but see https://gist.github.com/964fc632799a40f032beea0db1f265d5, which you can run yourself.
The problem is in TimeoutCatcherMiddleware#call
. If a function raises an exception, by definition that means you can't get the return value.
As far as I can tell, the solution is to stop the control flow from being short circuited in this gem.