Due to the TackCreationOptions.AttachToParent and our use of recursive method calls there was the potential of a StackOverflowException. This was not easily apparent since each task has it's own stack, however when all the tasks complete on a client disconnect that is when the StackOverflowException would occur.
At the same time though I didn't want to introduce any wait handles. So, to keep the request alive I added a TaskCompletionSource that IS attached to the parent that isn't set until the client disconnects, the channel disconnects, or an exception is thrown. In the event of an exception the TaskCompletionSource has the exception appended to it and exception logging is still handled in the AsyncInterceptExceptionBehavior.
Due to the
TackCreationOptions.AttachToParent
and our use of recursive method calls there was the potential of a StackOverflowException. This was not easily apparent since each task has it's own stack, however when all the tasks complete on a client disconnect that is when the StackOverflowException would occur.At the same time though I didn't want to introduce any wait handles. So, to keep the request alive I added a TaskCompletionSource that IS attached to the parent that isn't set until the client disconnects, the channel disconnects, or an exception is thrown. In the event of an exception the TaskCompletionSource has the exception appended to it and exception logging is still handled in the AsyncInterceptExceptionBehavior.