StackOverflowException coming from OrchardApiActionFilterDispatcher when ApiFilter present

Topics: Core, Troubleshooting
Developer
Aug 3, 2014 at 10: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?
Developer
Aug 3, 2014 at 11: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 4, 2014 at 12:11 AM
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: http://stackoverflow.com/questions/22152442/how-to-avoid-the-possible-stack-overflow-in-this-async-await-program


Developer
Aug 4, 2014 at 10:40 AM
Edited Aug 4, 2014 at 10: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.
Developer
Aug 4, 2014 at 11:21 AM
You can thank me later. I fixed it a while ago and forgot to push.

https://orchard.codeplex.com/SourceControl/changeset/45a876c479a2fc6adc94f5dd3193c5696124a7b1
Developer
Aug 4, 2014 at 1:11 PM
Thank you :-).