go-resty / resty

Simple HTTP and REST client library for Go
MIT License
10.01k stars 706 forks source link

Request body is written multiple times #743

Closed patrikeh closed 9 months ago

patrikeh commented 11 months ago

In v2.10.0, I've observed an issue where the request body passed to .SetBody(...) is intermittently written multiple times under certain conditions.

From what I gather, it is somehow related to the retry mechanism, or at the very least I was only able to reproduce by triggering that.

In the repro here, I ping an httptest mock endpoint triggering the retry mechanism, and observe the JSON request body being written multiple consecutive times e.g.


{ <some-json> }{ <some-json> }

This issue does not occur in v2.9.1.

iporer commented 11 months ago

My projcet recurred this bug. Hope fix. For more information, we tried all versions 2.8.0-2.10.0 and recurred in those versions.

lattwood commented 11 months ago

@patrikeh thanks for throwing that test case together, really helped with tracking the issue down