elixir-mint / mint

Functional HTTP client for Elixir with support for HTTP/1 and HTTP/2 🌱
Apache License 2.0
1.36k stars 112 forks source link

Mint.HTTP.connect can throw CaseClauseError #285

Closed sezaru closed 3 years ago

sezaru commented 3 years ago

Sometimes I get CaseClauseError during Mint.HTTP.connect call.

The error occurs in lib/min/negotiate.ex line 113 because transport.negotiated_protocol(socket) returns {:error, %Mint.TransportError{reason: :closed}}.

This is the error I got:

{:error,
     %Honeydew.Crash{
       reason: %CaseClauseError{term: {:error, %Mint.TransportError{reason: :closed}}},
       stacktrace: [
         {Mint.Negotiate, :alpn_negotiate, 5, [file: 'lib/mint/negotiate.ex', line: 113]},
         {Tesla.Adapter.Mint, :open_conn, 2, [file: 'lib/tesla/adapter/mint.ex', line: 157]},
         {Tesla.Adapter.Mint, :do_request, 5, [file: 'lib/tesla/adapter/mint.ex', line: 119]},
         {Tesla.Adapter.Mint, :call, 2, [file: 'lib/tesla/adapter/mint.ex', line: 59]},
         {Notification.Middlewares.FCM.Response, :call, 3,
          [file: 'lib/notification/middlewares/fcm/response.ex', line: 6]},
         {Tesla.Middleware.JSON, :call, 3, [file: 'lib/tesla/middleware/json.ex', line: 54]},
         {Honeydew.JobRunner, :do_run, 1, [file: 'lib/honeydew/job_runner.ex', line: 58]},
         {Honeydew.JobRunner, :handle_continue, 2, [file: 'lib/honeydew/job_runner.ex', line: 79]}
       ],
       type: :exception
     }}