Skip to content

Commit 9934f02

Browse files
committed
Prevent ping worker from dying on unexpected errors.
1 parent e6a3276 commit 9934f02

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
### 0.14.3 (Next)
22

3+
* [#279](https://github.com/slack-ruby/slack-ruby-client/pull/279): Prevent ping worker from dying on unexpected errors - [@dblock](https://github.com/dblock).
34
* Your contribution here.
45

56
### 0.14.2 (2019/4/12)

lib/slack/real_time/client.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ def run_ping!
128128
return if keep_alive?
129129

130130
restart_async
131+
rescue StandardError => e
132+
# disregard all ping worker failures, keep pinging
133+
logger.debug("#{self.class}##{__method__}") { e }
131134
end
132135

133136
def run_ping?

spec/slack/real_time/client_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,15 @@
148148
expect(socket).to receive(:restart_async)
149149
client.run_ping!
150150
end
151+
[EOFError, Errno::ECONNRESET, Errno::EPIPE, Faraday::ClientError].each do |err|
152+
context "raising #{err}" do
153+
it 'does not terminate the ping worker' do
154+
allow(socket).to receive(:time_since_last_message) { raise err }
155+
expect(socket).to_not receive(:send_data)
156+
client.run_ping!
157+
end
158+
end
159+
end
151160
end
152161
end
153162
end

0 commit comments

Comments
 (0)