From a781c2f98869750add423473a7961a04c4829150 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Mon, 28 Oct 2019 21:55:36 +0100 Subject: [PATCH] Wait for RCON connecting on FactorioServer.stop() If the RCON client is currently in the process of connecting to the Factorio server then wait for it to complete the connection to avoid it emmiting out an error connecting in FactorioServer.stop(). --- lib/factorio/server.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/factorio/server.js b/lib/factorio/server.js index d05cf4f3..afae615d 100644 --- a/lib/factorio/server.js +++ b/lib/factorio/server.js @@ -620,6 +620,13 @@ class FactorioServer extends events.EventEmitter { this._state = "stopping"; if (this._rconClient) { + + // If RCON is not yet fully connected that operation needs to + // complete before the RCON connection can be closed cleanly. + if (!this._rconReady) { + await events.once(this, 'rcon-ready'); + } + await this._rconClient.end(); }