heroku/heroku — Issue #176: `heroku logs` redirection into certain commands causes an unhandled exception.
Author: mmcgrana
Created: 2011-11-04 18:45:21+00:00
State: open

The `heroku logs` command does not seem to gracefully handle redirection into other shell commands that close their stdin pipe. For example:

$ heroku logs -a andvari-production | head -n 1
2011-11-04T18:40:29+00:00 app[web.2]: app=andvari deploy=production web request method=options path="/stats" at=finish elapsed=0.002
/Users/mmcgrana/.rvm/gems/ruby-1.8.7-p334/gems/heroku-2.11.1/lib/heroku/command/logs.rb:33:in `write': Broken pipe (Errno::EPIPE)
from /Users/mmcgrana/.rvm/gems/ruby-1.8.7-p334/gems/heroku-2.11.1/lib/heroku/command/logs.rb:33:in `puts'
from /Users/mmcgrana/.rvm/gems/ruby-1.8.7-p334/gems/heroku-2.11.1/lib/heroku/command/logs.rb:33:in `index'
from /Users/mmcgrana/.rvm/gems/ruby-1.8.7-p334/gems/heroku-2.11.1/lib/heroku/client.rb:392:in `read_logs'
from /Users/mmcgrana/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/net/protocol.rb:383:in `call_block'
from /Users/mmcgrana/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/net/protocol.rb:374:in `<<'
from /Users/mmcgrana/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/net/protocol.rb:102:in `read_all'
from /Users/mmcgrana/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/net/http.rb:2228:in `read_body_0'
from /Users/mmcgrana/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/net/http.rb:2181:in `read_body'
from /Users/mmcgrana/.rvm/gems/ruby-1.8.7-p334/gems/heroku-2.11.1/lib/heroku/client.rb:391:in `read_logs'
from /Users/mmcgrana/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/net/http.rb:1054:in `__request__'
from /Users/mmcgrana/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/net/http.rb:2144:in `reading_body'
from /Users/mmcgrana/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/net/http.rb:1053:in `__request__'
from /Users/mmcgrana/.rvm/gems/ruby-1.8.7-p334/gems/rest-client-1.6.3/lib/restclient/net_http_ext.rb:17:in `request'
from /Users/mmcgrana/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/net/http.rb:948:in `request_get'
from /Users/mmcgrana/.rvm/gems/ruby-1.8.7-p334/gems/heroku-2.11.1/lib/heroku/client.rb:390:in `read_logs'
from /Users/mmcgrana/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/net/http.rb:543:in `start'
from /Users/mmcgrana/.rvm/gems/ruby-1.8.7-p334/gems/heroku-2.11.1/lib/heroku/client.rb:389:in `read_logs'
from /Users/mmcgrana/.rvm/gems/ruby-1.8.7-p334/gems/heroku-2.11.1/lib/heroku/command/logs.rb:31:in `index'
from /Users/mmcgrana/.rvm/gems/ruby-1.8.7-p334/gems/heroku-2.11.1/lib/heroku/command.rb:114:in `send'
from /Users/mmcgrana/.rvm/gems/ruby-1.8.7-p334/gems/heroku-2.11.1/lib/heroku/command.rb:114:in `run'
from /Users/mmcgrana/.rvm/gems/ruby-1.8.7-p334/gems/heroku-2.11.1/bin/heroku:14
from /Users/mmcgrana/.rvm/gems/ruby-1.8.7-p334/bin/heroku:19:in `load'
from /Users/mmcgrana/.rvm/gems/ruby-1.8.7-p334/bin/heroku:19

I'm not sure, but I don't think this is desired. For example `cat file.txt | head -n 1` for a file of > 1 line works without error.

Meta:

$ heroku version
heroku-gem/2.11.1

$ ruby -v
ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin10.7.1]