diff --git a/package.json b/package.json index 90523bb5..fadd435c 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "root", "private": true, "scripts": { - "test": "mocha --exit --check-leaks -R spec --recursive test plugins/global_chat/test plugins/research_sync/test plugins/statistics_exporter/test plugins/subspace_storage/test", + "test": "mocha --check-leaks -R spec --recursive test plugins/global_chat/test plugins/research_sync/test plugins/statistics_exporter/test plugins/subspace_storage/test", "fast-test": "FAST_TEST=y npm test", "cover": "nyc npm test", "fast-cover": "FAST_TEST=y nyc npm test", @@ -32,6 +32,7 @@ "jszip": "^3.2.2", "lerna": "^3.22.1", "mocha": "^6.2.0", + "node-forge": "^0.10.0", "nyc": "^14.1.1", "phin": "^3.4.1", "webpack": "^5.0.0" diff --git a/packages/lib/link/connectors.js b/packages/lib/link/connectors.js index f3881d26..0932070f 100644 --- a/packages/lib/link/connectors.js +++ b/packages/lib/link/connectors.js @@ -211,6 +211,13 @@ class WebSocketClientConnector extends WebSocketBaseConnector { if (this._reconnectId) { clearTimeout(this._reconnectId); this._reconnectId = null; + this._lastReceivedSeq = null; + this._sessionToken = null; + this._sendBuffer.length = 0; + this._state = "new"; + this._connected = false; + this.emit("close"); + return; } this.stopHeartbeat(); diff --git a/packages/lib/package.json b/packages/lib/package.json index ee27b199..58133a27 100644 --- a/packages/lib/package.json +++ b/packages/lib/package.json @@ -19,7 +19,6 @@ "jsonwebtoken": "^8.2.1", "jszip": "^3.2.2", "klaw": "^3.0.0", - "node-forge": "^0.10.0", "rcon-client": "^4.2.0", "semver": "^7.1.1", "set-blocking": "^2.0.0", diff --git a/packages/master/package.json b/packages/master/package.json index 81e3faf5..937d5f0a 100644 --- a/packages/master/package.json +++ b/packages/master/package.json @@ -29,7 +29,6 @@ "jsonwebtoken": "^8.2.1", "jszip": "^3.2.2", "node-factorio-api": "^0.3.8", - "node-forge": "^0.10.0", "set-blocking": "^2.0.0", "winston": "^3.3.3", "ws": "^7.2.3", diff --git a/test/integration/index.js b/test/integration/index.js index 59051a18..f3ab1e76 100644 --- a/test/integration/index.js +++ b/test/integration/index.js @@ -175,6 +175,7 @@ after(async function() { masterProcess.kill("SIGINT"); await events.once(masterProcess, "exit"); } + await control.connector.close(); }); // Ensure the test processes are stopped. diff --git a/test/integration/link.js b/test/integration/link.js index 39848e16..183147f6 100644 --- a/test/integration/link.js +++ b/test/integration/link.js @@ -53,4 +53,12 @@ describe("Integration of lib/link", function() { await events.once(controlConnector, "invalidate"); await events.once(controlConnector, "connect"); }); + + it("should properly close connector if close is called during reconnect wait", async function() { + controlConnector._socket.close(1008, "Test"); + controlConnector.once("drop", () => { + controlConnector.close(); + }); + await events.once(controlConnector, "close"); + }); });