Exception using ServiceStack compression

A little context first. Our API has ExcludeTypeInfo set to true globally. We have one response object that returns an interface that so we had need to turn on IncludeTypeInfo for a specific service get call. I am testing the service and the Get call specified below with a unit test.

Initially I tried returning an HTTPResult that wrapped the response DTO and set the JSConfig with the following call:

return new HttpResult(response) { ResultScope = () => JsConfig.With(includeTypeInfo: true) };

We have compression enabled and our client is requesting compressed results.

In our class that inherits AppHostBase we have enabled compression in the OnAfterExecute with the following code.

public override object OnAfterExecute(IRequest requestContext, object response)
{
	if (response != null && !(response is CompressedResult))
	{
		string compressionType = requestContext.GetCompressionType();	
					
		// Note the method ToOptimizedResult (in src/ServiceStack/RequestExtensions.cs)
		// already checks the encoding header so we need not duplicate it here.
		response = requestContext.ToOptimizedResult(response);
	}

	return base.OnAfterExecute(requestContext, response);
}

When I return just the DTO from the call, compression works fine. If I return the HttpResult the call ToOptimizeResult causes W3WP.exe to fault and a debug dialog to appear. I attach to the process in another instance of VS ( because i am debugging the unit test ) and the exception is a stackoverflow exception in the call to requestContext.ToOptimizedResult(response); ( no stack trace because I am attaching ). Both Deflate and GZip fail.

If I enable includeTypeInfo globally and just return the DTO directly from the get call it is compressed just fine. If I turn off compression and return the HttpResult it works just fine.

To try another approach, I added the jsConfig=includeTypeInfo query params to my RequestDTO via ToURL impl from IUrlFilter and the call succeeded but it didn’t enable the property because the ResponseDTO interface members were null and I verified the queryparams were present from the IIS Logs. I tried setting includeTypeInfo, ExcludeTypeInfo:false with no success either.

Two questions, what is going on with returning an HttpResult from a Get call and Compression and barring that, how can I enable the IncludeTypeInfo from the client?

Can you create a stand-alone test which shows an issue so we’d be able to look into it?