Reject the RCON wait instead of resolving with an error

_waitForRconReadyOrExit resolved with an Error to signal the process
exited before RCON came up, which is an odd shape for a promise.  It now
resolves when RCON is ready and rejects otherwise, with the error emitted
with the exit, or "RCON connection lost" when there was none.

Observable behaviour is unchanged.  sendRcon rejects with the same
messages as before and stop ignores the rejection, as stopping is done
once the process is gone.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
bbassieandClaude Opus 5 committed 2026-09-13 17:29:41 +00:00
1 parent 0273558edc
commit 2a967e84c5
2 files changed
+21 -11

No files matched your search

+13
View File
@@ -61,6 +61,19 @@ describe("host/src/server", function() {
assert.equal(server.listenerCount("error"), 1);
});
it("does not reject if the process exits with an error before RCON is ready", async function() {
const server = createStartedServer();
const stopped = server.stop();
// The wait rejects with this error, stopping succeeds regardless.
server.emit("error", new lib.EnvironmentError("Factorio server was killed"));
server._server.emit("exit", null, "SIGKILL");
await assert.doesNotReject(withTimeout(stopped, "stop() did not resolve"));
assert.equal(server._state, "init");
assert.equal(server.listenerCount("rcon-ready"), 0);
assert.equal(server.listenerCount("exit"), 0);
assert.equal(server.listenerCount("error"), 1);
});
it("stops the server if RCON becomes ready", async function() {
const server = createStartedServer();
const stopped = server.stop();