Skip to content

Commit

Permalink
Handle EOFError, Errno::ECONNRESET, Errno::EPIPE in ping worker.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Jul 20, 2019
1 parent e6a3276 commit 5885323
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### 0.14.3 (Next)

* [#279](https://github.com/slack-ruby/slack-ruby-client/pull/279): Handle EOFError, Errno::ECONNRESET, Errno::EPIPE in ping worker - [@dblock](https://github.com/dblock).
* Your contribution here.

### 0.14.2 (2019/4/12)
Expand Down
3 changes: 3 additions & 0 deletions lib/slack/real_time/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ def run_ping!
return if keep_alive?

restart_async
rescue EOFError, Errno::ECONNRESET, Errno::EPIPE => e
# disregard restart failures, will retry again
logger.debug("#{self.class}##{__method__}") { e }
end

def run_ping?
Expand Down
9 changes: 9 additions & 0 deletions spec/slack/real_time/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@
expect(socket).to receive(:restart_async)
client.run_ping!
end
[EOFError, Errno::ECONNRESET, Errno::EPIPE].each do |err|
context "raising #{err}" do
it 'does not terminate the ping worker' do
allow(socket).to receive(:time_since_last_message) { raise err }
expect(socket).to_not receive(:send_data)
client.run_ping!
end
end
end
end
end
end
Expand Down

0 comments on commit 5885323

Please sign in to comment.