{"action":"created","issue":{"url":"https://api.github.com/repos/chrisroberts/krakow/issues/36","labels_url":"https://api.github.com/repos/chrisroberts/krakow/issues/36/labels{/name}","comments_url":"https://api.github.com/repos/chrisroberts/krakow/issues/36/comments","events_url":"https://api.github.com/repos/chrisroberts/krakow/issues/36/events","html_url":"https://github.com/chrisroberts/krakow/pull/36","id":92588418,"number":36,"title":"Safely handle EOFError on a IO#readpartial","user":{"login":"xmjw","id":255708,"avatar_url":"https://avatars.githubusercontent.com/u/255708?v=3","gravatar_id":"","url":"https://api.github.com/users/xmjw","html_url":"https://github.com/xmjw","followers_url":"https://api.github.com/users/xmjw/followers","following_url":"https://api.github.com/users/xmjw/following{/other_user}","gists_url":"https://api.github.com/users/xmjw/gists{/gist_id}","starred_url":"https://api.github.com/users/xmjw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xmjw/subscriptions","organizations_url":"https://api.github.com/users/xmjw/orgs","repos_url":"https://api.github.com/users/xmjw/repos","events_url":"https://api.github.com/users/xmjw/events{/privacy}","received_events_url":"https://api.github.com/users/xmjw/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-07-02T09:06:18Z","updated_at":"2015-07-03T14:00:02Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/chrisroberts/krakow/pulls/36","html_url":"https://github.com/chrisroberts/krakow/pull/36","diff_url":"https://github.com/chrisroberts/krakow/pull/36.diff","patch_url":"https://github.com/chrisroberts/krakow/pull/36.patch"},"body":"We've been using Krakow for a few months now, and it's fabulous. You're all awesome.\r\n\r\nWe have experienced occasional errors however, and I think it's a slightly peculiarity of the implementation: (ellipsis for readability)\r\n\r\n    Actor crashed! \r\n    EOFError: end of file reached \r\n      /app/vendor/bundle/ruby/2.1.0/gems/krakow-0.4.2/lib/krakow/ksocket.rb:55:in `readpartial' \r\n      .../krakow-0.4.2/lib/krakow/ksocket.rb:55:in `block (2 levels) in read_loop' \r\n      .../krakow-0.4.2/lib/krakow/ksocket.rb:95:in `socket' \r\n      .../krakow-0.4.2/lib/krakow/ksocket.rb:55:in `block in read_loop' \r\n      .../celluloid-0.16.0/lib/celluloid/calls.rb:26:in `call' \r\n      .../celluloid-0.16.0/lib/celluloid/calls.rb:26:in `public_send' \r\n      .../celluloid-0.16.0/lib/celluloid/calls.rb:26:in `dispatch' \r\n      .../celluloid-0.16.0/lib/celluloid/calls.rb:63:in `dispatch' \r\n      .../celluloid-0.16.0/lib/celluloid/future.rb:14:in `block in new' \r\n      .../celluloid-0.16.0/lib/celluloid/thread_handle.rb:13:in `block in initialize' \r\n      .../celluloid-0.16.0/lib/celluloid/actor_system.rb:32:in `block in get_thread' \r\n      .../celluloid-0.16.0/lib/celluloid/internal_pool.rb:130:in `call' \r\n      .../celluloid-0.16.0/lib/celluloid/internal_pool.rb:130:in `block in create' \r\n      (celluloid):0:in `remote procedure call' \r\n      .../celluloid-0.16.0/lib/celluloid/future.rb:104:in `value' \r\n      .../celluloid-0.16.0/lib/celluloid/future.rb:68:in `value' \r\n      .../celluloid-0.16.0/lib/celluloid.rb:439:in `defer' \r\n      .../krakow-0.4.2/lib/krakow/ksocket.rb:53:in `read_loop' \r\n      .../celluloid-0.16.0/lib/celluloid/calls.rb:26:in `public_send' \r\n      .../celluloid-0.16.0/lib/celluloid/calls.rb:26:in `dispatch' \r\n      .../celluloid-0.16.0/lib/celluloid/calls.rb:122:in `dispatch'  \r\n      .../celluloid-0.16.0/lib/celluloid/cell.rb:60:in `block in invoke' \r\n      .../celluloid-0.16.0/lib/celluloid/cell.rb:71:in `block in task' \r\n      .../celluloid-0.16.0/lib/celluloid/actor.rb:357:in `block in task' \r\n      .../celluloid-0.16.0/lib/celluloid/tasks.rb:57:in `block in initialize' \r\n      .../celluloid-0.16.0/lib/celluloid/tasks/task_fiber.rb:15:in `block in create' \r\n\r\nI've spent some time digging, and this seems to be because the `IO#readpartial` legitimately raises an `EOFError` when there is [nothing to read](http://ruby-doc.org/core-2.2.2/IO.html#method-i-readpartial). Because this isn't handled, an EOF on a socket causes the whole system to crash. Weirdly, this is only an issue with *some* of the services we're running with Krakow, but this should make the whole thing a little more stable.\r\n\r\nApologies if this is completely the wrong way to go with this, but I wanted to open with some code rather than just open an issue and hope someone else will fix it! Let me know what you think."},"comment":{"url":"https://api.github.com/repos/chrisroberts/krakow/issues/comments/118359158","html_url":"https://github.com/chrisroberts/krakow/pull/36#issuecomment-118359158","issue_url":"https://api.github.com/repos/chrisroberts/krakow/issues/36","id":118359158,"user":{"login":"xmjw","id":255708,"avatar_url":"https://avatars.githubusercontent.com/u/255708?v=3","gravatar_id":"","url":"https://api.github.com/users/xmjw","html_url":"https://github.com/xmjw","followers_url":"https://api.github.com/users/xmjw/followers","following_url":"https://api.github.com/users/xmjw/following{/other_user}","gists_url":"https://api.github.com/users/xmjw/gists{/gist_id}","starred_url":"https://api.github.com/users/xmjw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xmjw/subscriptions","organizations_url":"https://api.github.com/users/xmjw/orgs","repos_url":"https://api.github.com/users/xmjw/repos","events_url":"https://api.github.com/users/xmjw/events{/privacy}","received_events_url":"https://api.github.com/users/xmjw/received_events","type":"User","site_admin":false},"created_at":"2015-07-03T14:00:02Z","updated_at":"2015-07-03T14:00:02Z","body":"Sure thing @mreiferson. So I'm wondering if we should somehow get this to cause a socket connection to reset. But if we let it raise it'll go to Celluloid and bring the application down.\r\n\r\nBeyond adding some logging out on this, I'm not really sure what else can be done. \r\n\r\nI think it's fair to say this shouldn't cause a crash, but I know very little about Celluloid and Krakow, so if you've any guidance on how to deal with this, I'm happy to go hack around and figure out a better solution? Otherwise I'lll just keep tinkering until I get something that seems reasonable...\r\n\r\nTa."}}