From 9f037eafd22abff362ede37279cd83aeeab4493c Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Wed, 29 May 2019 09:28:04 +0100 Subject: [PATCH] fix waitgroup bug which crashes subscriber --- server/subscriber.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/server/subscriber.go b/server/subscriber.go index b9a50a7b..77971565 100644 --- a/server/subscriber.go +++ b/server/subscriber.go @@ -244,9 +244,15 @@ func (s *rpcServer) createSubHandler(sb *subscriber, opts Options) broker.Handle fn = opts.SubWrappers[i-1](fn) } - s.wg.Add(1) + if s.wg != nil { + s.wg.Add(1) + } + go func() { - defer s.wg.Done() + if s.wg != nil { + defer s.wg.Done() + } + results <- fn(ctx, &rpcMessage{ topic: sb.topic, contentType: ct,