fsprojects / FSharp.Data

F# Data: Library for Data Access
https://fsprojects.github.io/FSharp.Data
Other
816 stars 287 forks source link

Unexpected System.ArgumentException #1123

Closed pavel-rosputko closed 6 years ago

pavel-rosputko commented 6 years ago

some requests fails with

System.ArgumentException: Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.
   at FSharp.Data.HttpHelpers.augmentWebExceptionsWithDetails@1207-2.Invoke(Exception _arg1)
   at Microsoft.FSharp.Control.AsyncBuilderImpl.callA@839.Invoke(AsyncParams`1 args)

usage

let body = req.Body |> Json.formatWith JsonFormattingOptions.Compact |> HttpRequestBody.TextRequest
let res = Http.RequestString(url=req.Url, httpMethod = "POST", body = body)

no specific pattern observed. replaced with .net core http library

let body = lpreq.Body |> Json.formatWith JsonFormattingOptions.Compact
let req = HttpWebRequest.Create(lpreq.Url) :?> HttpWebRequest 
req.ProtocolVersion <- HttpVersion.Version10
req.Method <- "POST"
let postBytes = Encoding.ASCII.GetBytes(body)
req.ContentType <- "application/json"
req.ContentLength <- int64 postBytes.Length

let reqStream = req.GetRequestStream() 
reqStream.Write(postBytes, 0, postBytes.Length);
reqStream.Close()

let resp = req.GetResponse() 
let stream = resp.GetResponseStream() 
let reader = new StreamReader(stream) 
let res = reader.ReadToEnd()

everything is fine. looks like some internal bug!?

baronfel commented 6 years ago

Quite possibly, can you get us the URL and body that raised the error?

ovatsus commented 6 years ago

Closing due to no repro