Problem with ToOptimizedResult

Hello,

When I change GET method to use “ToOptimizedResult” in MyService class in default SelfHost template like this:

namespace SelfHost1.ServiceInterface
{
    public class MyServices : Service
    {
        public object Any(Hello request)
        {
            return Request.ToOptimizedResult(new HelloResponse { Result = "Hello, {0}!".Fmt(request.Name) });
        }
    }
}

response takes about 2min:

I’m getting same results with ToOptimizeResultUsingCache. Is there a bug in latest release (4.0.54.0) or I am doing something wrong?

I can’t reproduce this, I’ve created a new ServiceStack v4.0.54 Self Host Empty project, modified MyServices with your implementation, refreshed about 50 times but haven’t seen any slow requests over 20ms, Web Inspector is reporting each request between 4-12ms:

Do you have access to another pc you can try this on?

Yes, I have tried on another pc and it’s working fine, but when I turn on Request logger with Response logging it returns error when using ToOptimizedResult.

        public override void Configure(Container container)
        {
            //Config examples
            //this.Plugins.Add(new PostmanFeature());
            //this.Plugins.Add(new CorsFeature());
            Plugins.Add(new RequestLogsFeature()
            {
                EnableResponseTracking = true,
                EnableRequestBodyTracking = true,
                EnableErrorTracking = true
            });
        }

Without ToOptimezedResult logger returns dto responses correctly.
I don’t know is this connected somehow - tomorrow I will try on few more computers.

The serialization error was due to the Request Logger trying to serialize the non-serializable CompressedResult wrapper Response when EnableResponseTracking=true.

I’ve changed it to only serialize the inner response (i.e. instead of the IHttpResult wrapper) in this commit.

This change is available from v4.0.55 that’s now available on MyGet.