diff --git a/CHANGELOG.md b/CHANGELOG.md index 5db850a2..a5b4b887 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/lib/slack/real_time/client.rb b/lib/slack/real_time/client.rb index 0558fb48..63ea677b 100644 --- a/lib/slack/real_time/client.rb +++ b/lib/slack/real_time/client.rb @@ -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? diff --git a/spec/slack/real_time/client_spec.rb b/spec/slack/real_time/client_spec.rb index 488a8a73..67964bea 100644 --- a/spec/slack/real_time/client_spec.rb +++ b/spec/slack/real_time/client_spec.rb @@ -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