Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

With Giraffe 3.6.0, BindJsonAsync in task CE yields runtime error message "Synchronous operations are disallowed. Call ReadAsync or set AllowSynchronousIO to true instead." #351

Closed
cpbotha opened this issue Apr 13, 2019 · 3 comments
Labels
bug Reproducible bug ready for release Issue has been already resolved in the development branch

Comments

@cpbotha
Copy link

cpbotha commented Apr 13, 2019

In a POST handler task CE, the following code yields the error message in the title of this issue:

let! body = ctx.BindJsonAsync<NewCommentBody>()

However, by instead following the lead of BindXmlAsync's implementation, the following code works perfectly:

let serializer = ctx.GetJsonSerializer()
let! bodyText = ctx.ReadBodyFromRequestAsync()
let body = serializer.Deserialize<NewCommentBody> bodyText;

You can compare the implementations of BindJsonAsync and BindXmlAsync here: https://github.com/giraffe-fsharp/Giraffe/blob/master/src/Giraffe/ModelBinding.fs#L241

@slang25
Copy link
Member

slang25 commented Apr 14, 2019

I've managed to recreate this, it looks like we would need Json.NET to add a DeserializeAsync entry point (they have async readers already) JamesNK/Newtonsoft.Json#1193

Microsoft are also bringing a new fast and async library for working with JSON which would be a good idea to offer too. I'm happy to work on this when it matures.

@dustinmoris dustinmoris added bug Reproducible bug help wanted Community contribution or any kind of help much appreciated PR approved A PR for this issue will get accepted (as long as inline with the comms) labels Apr 16, 2019
@dv00d00
Copy link
Contributor

dv00d00 commented Apr 26, 2019

Should not this be working fine with Utf8JsonSerializer ?

@dustinmoris dustinmoris added ready for release Issue has been already resolved in the development branch and removed PR approved A PR for this issue will get accepted (as long as inline with the comms) help wanted Community contribution or any kind of help much appreciated labels Aug 24, 2019
@dustinmoris
Copy link
Member

Out in 4.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Reproducible bug ready for release Issue has been already resolved in the development branch
Projects
None yet
Development

No branches or pull requests

4 participants