Describe the bug
In 10.1, with dotnet core 3, using HttpGetSchemaMiddleware, I get the following exeption:
System.InvalidOperationException: Synchronous operations are disallowed. Call WriteAsync or set AllowSynchronousIO to true instead.
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpResponseStream.Flush()
at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
at System.IO.StreamWriter.Dispose(Boolean disposing)
at System.IO.TextWriter.Dispose()
at HotChocolate.AspNetCore.HttpGetSchemaMiddleware.InvokeAsync(HttpContext context)
at HotChocolate.AspNetCore.QueryMiddlewareBase.InvokeAsync(HttpContext context)
at HotChocolate.AspNetCore.QueryMiddlewareBase.InvokeAsync(HttpContext context)
at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Builder.Extensions.MapWhenMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Builder.Extensions.MapWhenMiddleware.Invoke(HttpContext context)
Desktop (please complete the following information):
mcr.microsoft.com/dotnet/core/aspnet:3.0-alpineWe're in the process of moving some of our services to .NET Core 3 and running to this issue as well.
Updating SchemaSyntaxSerializer to be fully asynchronous isn't viable, most of the use cases of SyntaxVisitor would be hindered by it being asynchronous.
In the interim we could have SchemaSyntaxSerializer write synchronously to an in memory stream and write that asynchronously to the response.
@nigel-sampson 聽Yes, this could be a quick fix. I want to rework the visitors for V11 but in the meantime this could be a good solution. Do you want to implement that? I have another fix already in the version_10_0_0 master so we could create 10.2.1 with these two fixes.
Yup, I'll handle it sometime in the next few days.
This issue is fixed with 10.4
Most helpful comment
Yup, I'll handle it sometime in the next few days.