benoitc / hackney

simple HTTP client in Erlang
Other
1.34k stars 427 forks source link

FunctionClauseError no function clause matching in :hackney_response.stream_body_recv/2 #730

Closed spyrbri closed 4 months ago

spyrbri commented 11 months ago

Hello, after upgrading from 1.18.1 to 1.19.1 we started getting this error.

It happens randomly. One request may pass through but the next may fail.

FunctionClauseError: no function clause matching in :hackney_response.stream_body_recv/2
:hackney_response.stream_body_recv/2 (hackney)(/app/deps/hackney/src/hackney_response.erl:169)
:hackney_response.read_body/3 (hackney)(/app/deps/hackney/src/hackney_response.erl:312)
anonymous fn/1 in :hackney.body/1 (hackney)(/app/deps/hackney/src/hackney.erl:510)
Tesla.Adapter.Hackney.handle/1 (tesla)(lib/tesla/adapter/hackney.ex:102)
Tesla.Adapter.Hackney.call/2 (tesla)(lib/tesla/adapter/hackney.ex:33)
Tesla.Middleware.FollowRedirects.redirect/3 (tesla)(lib/tesla/middleware/follow_redirects.ex:46)
Tesla.Middleware.JSON.call/3 (tesla)(lib/tesla/middleware/json.ex:54)

This is an example of a failed request

:hackney_response.stream_body_recv("", 
  {:client, {1699, 521127, 152004}, 
   {:metrics_ng, :metrics_dummy}, 
   :hackney_tcp, '[ANONYMIZED_HOST]', 80, 
   "[ANONYMIZED_HOST]", [recv_timeout: 5000], 
   #Port<0.3196>, 
   {:default, #Reference<0.3739800695.3888119809.153571>, 
    {:connection, :hackney_tcp, '[ANONYMIZED_HOST]', 80, 109744905, false}, 
    #PID<0.861.0>, 
    :hackney_tcp}, 
   #Reference<0.3739800695.3888119809.153571>, 
   true, 
   :hackney_pool, 
   5000, 
   false, 
   5, 
   false, 
   5, 
   nil, 
   nil, 
   {:hparser, :response, 4096, 10, 0, 
    :on_trailers, "\r", {1, 1}, "", [], :undefined, 
    "chunked", "keep-alive", "application/json; charset=utf-8", "", :done}, 
   {16, 
    {:dict, 16, 16, 16, 8, 80, 48, 
     {[], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []}, 
     {{[], 
       [["server-timing", {15, "Server-Timing", "total;dur=106.72569298185408"}]], 
       ["x-content-type-options", {6, "X-Content-Type-Options", "nosniff"}], 
      [], 
      [], 
      [["etag", {11, "ETag", "W/\"1217c0895af4af2440e1ea3724ebe820\""}]], 
       ["x-permitted-cross-domain-policies", {8, "X-Permitted-Cross-Domain-Policies", "none"}], 
       ["cache-control", {12, "Cache-Control", "max-age=0, private, must-revalidate"}]], 
      [["x-download-options", {7, "X-Download-Options", "noopen"}]], 
      [], 
      [["content-type", {1, "Content-Type", ...}], 
       ["transfer-encoding", {2, ...}]], 
      [["referrer-policy", {9, ...}]], 
      [["connection", {...}], ["x-frame-options", ...], [...]], 
      [], 
      [], 
      []}}}}, 
   :connected, 
   :waiting, 
   nil, 
   :normal, 
   false, 
   false, 
   false, 
   :undefined, 
   false, 
   &:hackney_request.send/2, 
   :waiting, 
   nil, 
   4096, 
   "", 
   [], 
   {1, 1}, 
   :undefined, 
   "chunked", 
   nil, 
   "POST", 
   "/path", 
   nil})

Do you have any idea why this can be happening?

TeoDiaz commented 10 months ago

I have the same issue with version 1.18.2.

Logs point me out to this line

benoitc commented 10 months ago

Did you try latest version ? This issue should be solved but let me know.

TeoDiaz commented 10 months ago

Hi @benoitc , This morning I just update to the 1.20.1 and since then I have not seen the error again, so I think it's solved.

Is there any place were we can see the Changelog or what fixes where implemented on each version?

benoitc commented 10 months ago

The change log is here : https://github.com/benoitc/hackney/blob/master/NEWS.md

TeoDiaz commented 10 months ago

Thanks a lot, so I can confirm that this issue was fixed by my side, let see if @spyrbri can update the version.

Thanks for the response.

spyrbri commented 10 months ago

It looks ok for us too, thank you! 🎆

benoitc commented 4 months ago

closing as done.