StackOverflowException coming from OrchardApiActionFilterDispatcher when ApiFilter present

Topics: Core, Troubleshooting
Aug 3, 2014 at 9:54 PM
I have a module with a very simple API filter:
    public class TestApiFilter : ActionFilterAttribute, IApiFilterProvider
        public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
Yes, it's empty!

Even if the module it resides in is not enabled I get a SO exception: "An unhandled exception of type 'System.StackOverflowException' occurred in System.Web.Http.dll" This is coming from OrchardApiActionFilterDispatcher where the actionFilter.ExecuteActionFilterAsync() on ln 17 apparently leads to repeated such calls. Strange thing is, if I place a breakpoint there I can't see this in action, I just get the exception (I get notified about an exception happening in w3wp.exe and asked to debug it; I can't see the exception when the debugger is already attached).

Anybody seen this?
Aug 3, 2014 at 10:46 PM
Hmm, interesting. After I restarted the site (and the server, local IIS) a few times, then commented out the whole class to be able to work, then reverted the commenting and restarting the site I can't see the error any more. So the code is exactly the same as before, when SO happened, but no error this time... Wat.
Aug 3, 2014 at 11:11 PM
I'm not sure if this makes sense at all, but maybe autofac got confused and resolved the OrchardApiActionFilterDispatcher itself, even though it's not an IApiFilterProvider?

Or there is this, if this applies:

Aug 4, 2014 at 9:40 AM
Edited Aug 4, 2014 at 9:41 AM
Interesting SO post, thanks!

OrchardApiActionFilterDispatcher is not registered with Autofac, neither gets it instantiated multiple times (I checked). Also I can't reproduce the issue any more locally (nothing changed) neither happens it on the server fortunately.
Aug 4, 2014 at 10:21 AM
You can thank me later. I fixed it a while ago and forgot to push.
Aug 4, 2014 at 12:11 PM
Thank you :-).