From 4bdc49d11de23a8bff80a5a43aea04d639020a14 Mon Sep 17 00:00:00 2001 From: Giorgi Bochorishvili Date: Mon, 23 Jan 2023 16:33:45 +0400 Subject: [PATCH] Fix potential nil dereference error --- app/server.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/server.go b/app/server.go index 8358ef4986..78cea110c4 100644 --- a/app/server.go +++ b/app/server.go @@ -263,6 +263,13 @@ func NewServer(options ...Option) (*Server, error) { return nil, errors.Wrap(err, "failed to initialize products") } + // After channel is initialized set it to the App object + channelsWrapper, ok := serviceMap[product.ChannelKey].(*channelsWrapper) + if !ok { + return nil, errors.Wrap(err, "channels product is not initialized") + } + app.ch = channelsWrapper.app.ch + // It is important to initialize the hub only after the global logger is set // to avoid race conditions while logging from inside the hub. // Step 5: Start hub in platform which the hub depends on s.Channels() (step 4)