diff --git a/network/engine.go b/network/engine.go index a1820b79..fba52f92 100644 --- a/network/engine.go +++ b/network/engine.go @@ -52,10 +52,12 @@ func (engine *Engine) Stop(ctx context.Context) error { defer cancel() engine.running.Store(false) - if err := engine.listener.Close(); err != nil { - engine.stopServer <- struct{}{} - close(engine.stopServer) - return gerr.ErrCloseListenerFailed.Wrap(err) + if engine.listener != nil { + if err := engine.listener.Close(); err != nil { + engine.stopServer <- struct{}{} + close(engine.stopServer) + return gerr.ErrCloseListenerFailed.Wrap(err) + } } engine.stopServer <- struct{}{} close(engine.stopServer)