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,