Skip to content

Commit 2cfba1d

Browse files
committed
Merge branch 'pr-177'
This closes #177
2 parents 3a4af34 + 211a305 commit 2cfba1d

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 2021-??-?? - 1.3.1
4+
5+
- [177](https://github.com/Smashing/smashing/pull/177) Remove websocket connections that have been closed in send_event (thanks @ssgelm)
6+
37
## 2020-06-04 - 1.3.0
48

59
- [#157](https://github.com/Smashing/smashing/pull/157) Update gems

lib/dashing/app.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,13 @@ def send_event(id, body, target=nil)
144144
body[:updatedAt] ||= (Time.now.to_f * 1000.0).to_i
145145
event = format_event(body.to_json, target)
146146
Sinatra::Application.settings.history[id] = event unless target == 'dashboards'
147-
Sinatra::Application.settings.connections.each { |out| out << event }
147+
Sinatra::Application.settings.connections.each { |out|
148+
begin
149+
out << event
150+
rescue IOError => e # if the socket is closed an IOError is thrown
151+
Sinatra::Application.settings.connections.delete(out)
152+
end
153+
}
148154
end
149155

150156
def format_event(body, name=nil)

0 commit comments

Comments
 (0)