2

While executing the POST or PUSH requests in Postman for the following repository (https://github.com/websharper-samples/PeopleAPI),

I am getting this error : System.InvalidOperationException: Synchronous operations are disallowed. Call ReadAsync or set AllowSynchronousIO to true instead. Error Screenshot

How do I set AllowSynchronousIO to true in f# to execute POST or PUSH requests for an API?

  • Welcome to the F# community. This question might be a duplicate of https://stackoverflow.com/questions/47735133/asp-net-core-synchronous-operations-are-disallowed-call-writeasync-or-set-all – Scott Hutchinson Dec 14 '20 at 01:21
  • See also https://github.com/dotnet-websharper/aspnetcore/issues/9 – Scott Hutchinson Dec 14 '20 at 01:25
  • And https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=2ahUKEwiS4Y6kqMztAhUVt54KHZmxA38QFjAAegQIARAC&url=https%3A%2F%2Fgitter.im%2Fintellifactory%2Fwebsharper&usg=AOvVaw2czVH-2S_EI90Ub9Hj9mnN – Scott Hutchinson Dec 14 '20 at 01:26

1 Answers1

1

Extremely late to the party. I had this problem with Giraffe F#. Fixed it by changing

WebHostBuilder()
    .UseKestrel()
    .UseContentRoot(contentRoot)
    .UseIISIntegration()
    .UseWebRoot(webRoot)
    .ConfigureAppConfiguration(Action<WebHostBuilderContext, IConfigurationBuilder> configureAppConfiguration)
    .Configure(Action<IApplicationBuilder> configureApp)
    .ConfigureServices(configureServices)
    .ConfigureLogging(configureLogging)
    .Build()
    .Run()

to

WebHostBuilder()
    .UseKestrel(Action<KestrelServerOptions> configKestrel)
    .UseContentRoot(contentRoot)
    .UseIISIntegration()
    .UseWebRoot(webRoot)
    .ConfigureAppConfiguration(Action<WebHostBuilderContext, IConfigurationBuilder> configureAppConfiguration)
    .Configure(Action<IApplicationBuilder> configureApp)
    .ConfigureServices(configureServices)
    .ConfigureLogging(configureLogging)
    .Build()
    .Run()

and the configKestrel function looks like:

let configKestrel (opts : KestrelServerOptions) =
    opts.AllowSynchronousIO <- true
Dharman
  • 30,962
  • 25
  • 85
  • 135