StaticFileCompression Net5 Synchronous operations are disallowed

Hi,

When using StaticFileCompression (https://docs.servicestack.net/compression#static-file-compression) on Net5 we get the following error:

fail: ServiceStack.Host.Handlers.StaticFileHandler[0]
  Static file /js/servicestack-client.js forbidden: Synchronous operations are disallowed. Call WriteAsync or set AllowSynchronousIO to true instead.

Seems to be the outputStream.Close which internally uses a non-async “Write” in Dispose

To repro, we created a new 5.12.1 project using the cli (x new web WebApp), and added CompressFilesWithExtensions = { "js", "css" } on the HostConfig. Then run the app on Kestrel and disabling the browser caching to get the error every time we load up the webpage.

Thanks!

This should be resolved from this commit, this change is now available from v5.12.1+ that’s now available on MyGet.

As the .NET 5 project templates contain a NuGet.Config which is already configured to use the latest pre-release packages on MyGet, you should be able to get the latest version by clearing your NuGet packages cache and re-creating the web template, e.g:

$ nuget locals all -clear
$ x new web WebApp

thx for reporting!

1 Like