From 6165030ab5dabbf60d79d545343de8f4a1c1b03a Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Mon, 10 Nov 2014 21:13:18 -0800 Subject: [PATCH] prevent panic when replaying on closed channel --- server/pubsub/channel.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/pubsub/channel.go b/server/pubsub/channel.go index 63001c5fe..33f2a1fa7 100644 --- a/server/pubsub/channel.go +++ b/server/pubsub/channel.go @@ -111,6 +111,12 @@ func (c *Channel) start() { } func replay(s *Subscription, history []interface{}) { + defer func() { + if r := recover(); r != nil { + log.Println("recoved from panic", r) + } + }() + for _, msg := range history { s.send <- msg }