ninenines / gun

HTTP/1.1, HTTP/2, Websocket client (and more) for Erlang/OTP.
ISC License
891 stars 232 forks source link

MatchError in :gun.info/1 #222

Closed alex-strizhakov closed 4 years ago

alex-strizhakov commented 4 years ago

Hey! Sometimes in logs i see MatchError for :gun.info/1 calls.

** (MatchError) no match of right hand side value: {:error, :einval}
(gun 2.0.0-pre.1) /home/pleroma/deps/gun/src/gun.erl:434: :gun.info/1

Gun is used from master branch and :gun.info/1 is called after :gun_up message. Not quite sure what is causing this.

essen commented 4 years ago

Makes sense, Transport:sockname/1 isn't guaranteed to succeed, for example if the socket is not connected. In that case it should act like undefined I think, meaning the ip/port would not be included in the info (we don't have them anyway).

https://github.com/ninenines/gun/blob/74ac4d209c86f64059b1eaa0e541eb7d26dd23a8/src/gun.erl#L434

alex-strizhakov commented 4 years ago

Sounds good

essen commented 4 years ago

I will do this change and prepare a new pre-release on Wednesday.

essen commented 4 years ago

Done locally, push soon. Thanks!