Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling EPIPE during write #430

Closed
milgner opened this issue Sep 8, 2017 · 3 comments · Fixed by #436
Closed

Handling EPIPE during write #430

milgner opened this issue Sep 8, 2017 · 3 comments · Fixed by #436

Comments

@milgner
Copy link

milgner commented Sep 8, 2017

While trying to send a request, something happens (still investigating the source of the problem, it might be the server dropping the connection), resulting in a EPIPE error.
Would I be correct in assuming that this best be caught in the request writer? If so, I can prepare a PR to that effect.
Of course I'm open to other suggestions :)

(main)> err.backtrace
=> [
    [ 0] "<internal:prelude>:134:in `__write_nonblock'",
    [ 1] "<internal:prelude>:134:in `write_nonblock'",
    [ 2] "/app/vendor/bundle/ruby/2.3.0/gems/http-2.2.2/lib/http/timeout/per_operation.rb:77:in `block in write'",
    [ 3] "/app/vendor/bundle/ruby/2.3.0/gems/http-2.2.2/lib/http/timeout/per_operation.rb:76:in `loop'",
    [ 4] "/app/vendor/bundle/ruby/2.3.0/gems/http-2.2.2/lib/http/timeout/per_operation.rb:76:in `write'",
    [ 5] "/app/vendor/bundle/ruby/2.3.0/gems/http-2.2.2/lib/http/request/writer.rb:99:in `write'",
    [ 6] "/app/vendor/bundle/ruby/2.3.0/gems/http-2.2.2/lib/http/request/writer.rb:87:in `block in send_request'",
@janko
Copy link
Member

janko commented Oct 14, 2017

@milgner Yes, the Errno::EPIPE exception is most likely caused by the server closing the TCP connection. I would think so, because the same exception is raised when using Ruby pipes, where you try to write to the write end of the pipe while after the read end was closed.

read_end, write_end = IO.pipe
read_end.close
write_end.write("content") # Errno::EPIPE: Broken pipe

I think it would be appropriate to raise a HTTP::ConnectionError in this case, and HTTP::Request::Writer looks like an appropriate place to rescue that error.

@milgner It would be great if you could open a PR for this, as it confused me as well recently. I only knew what happened because I'm familiar with the Errno::EPIPE exception from using Ruby pipes.

@janko
Copy link
Member

janko commented Oct 14, 2017

I already opened a PR – #436 😛

@milgner
Copy link
Author

milgner commented Oct 15, 2017

Nice! I was afk for the weekend, thank you for the quick patch! 👍

@ixti ixti closed this as completed in #436 Oct 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants