Unable to set request.WaitTimeout beyond 30s for NewHTMLRequest
sahil-weave opened this issue · 1 comments
Hi,
I am trying to convert an HTML to PDF using this gotenberg-go-client.
Below is a sample code:
doc, err := gotenberg.NewDocumentFromString("document.html", finalHtml)
if err != nil {
return nil, werror.Wrap(err, "error reading html")
}
req := gotenberg.NewHTMLRequest(doc)
req.Margins([4]float64{0, 0.5, 0.5, 0.5})
req.Assets(style)
req.PaperSize(gotenberg.A4)
req.Scale(0.8)
req.Footer(footer)
req.WaitTimeout(40)
generatedAPIResponse, err := client.Post(req)
if err != nil {
return nil, werror.Wrap(err, "error while making request to PDF generator")
}
I am getting a strange 400 on updating the wait timeout via go. I have added the logs below.
I am unable to set the timeout larger than 30s via go.
Expected Behavior
The request timeOut should have been updated to 40.
Current Behavior
I get an HTTP 400 Bad request in generatedAPIResponse.StatusCode. In debugger, I can see this
HTTP/1.1 400 Bad Request
Content-Type: application/json; charset=UTF-8
Date: Tue, 23 May 2023 15:57:34 GMT
Content-Length: 74
{"message":"'waitTimeout' should be \u003c '30.000000', got '40.000000'"}
On enabling low level debugger running locally on gotenberg v6 image on a similar request, I can get to this message :
{"level":"error","msg":"\u003cinvalid\u003e 'waitTimeout' should be \u003c '30.000000', got '40.000000'","op":"xhttp.htmlHandler: xhttp.chromePrinterOptions: resource.WaitTimeoutArg: resource.Resource.Float64Arg: xassert.Float64: xassert.ruleFloat64NotSuperiorTo.validate","time":"2023-05-23T16:19:02Z","trace":"QCdtq3pMO0pty06WBGcYGyewi6vxN73d"}
Steps to Reproduce (for bugs)
- run docker image on local system for gotenberg v6
- Use the go code mentioned:
doc, err := gotenberg.NewDocumentFromString("document.html", finalHtml)
if err != nil {
return nil, werror.Wrap(err, "error reading html")
}
req := gotenberg.NewHTMLRequest(doc)
req.Margins([4]float64{0, 0.5, 0.5, 0.5})
req.Assets(style)
req.PaperSize(gotenberg.A4)
req.Scale(0.8)
req.Footer(footer)
req.WaitTimeout(40)
generatedAPIResponse, err := client.Post(req)
if err != nil {
return nil, werror.Wrap(err, "error while making request to PDF generator")
}
- I am using v7 go-gotenberg-client but using a gotenber v6 docker image as it was mentioned in readme that there are some issues with >=7.x gotenberg
generatedAPIResponse.StatusCode
returns 400
Context
I got some long HTML content that takes >30s to process, therefore the default 30s waitTimeout is not enough. I saw in docs that we can update that.
I can set the timeOut to 0 and 30 , it works as expected (timeOut error) but any integer value >30 results in 400 BAD request.
I can get smaller HTML content to PDFs easily but the problem is specific to some cases where content is large.
Your Environment
- Version used: github.com/thecodingmachine/gotenberg-go-client/v7
*docker image: "thecodingmachine/gotenberg:6.4.4"
Hello @sahil-weave,
I do not maintain anymore this package, nor Gotenberg 6.
Consider switching to Gotenberg 7 and writing simple http requests with form fields in Go.