Require Factorio 2.1.12 for Lua UDP

Factorio 2.0.59 through 2.1.11 crash with "Trying to add invalid input
action to the closure" when helpers.recv_udp dispatches a received
packet, whether polled from on_tick or called from a command and
whether or not the server is paused.  Reproduced on headless 2.0.77 and
2.1.8, works from 2.1.12 on.  FactorioServer now refuses to start with
Lua UDP enabled on older versions, the docs say 2.1.12, and the
integration tests only enable it on 2.1.12 or later.

The to-game integration test polls recv_udp from on_tick like the
clusterio module does and sends commands to make the empty server tick.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
bbassieandClaude Fable 5.1 committed 2026-10-15 16:38:34 +00:00
1 parent 7a64706c82
commit 1f37905be0
8 files changed
+37 -10

No files matched your search

+14
View File
@@ -365,6 +365,20 @@ describe("host/server", function() {
return { lines, restore: () => { server._logger = logger; } };
}
it("should refuse to start on Factorio before 2.1.12", async function() {
const version = server._version;
server._version = "2.1.11";
server.enableLuaUdp = true;
try {
const error = new Error("Lua UDP requires Factorio 2.1.12 or later");
await assert.rejects(server.start("save.zip"), error);
await assert.rejects(server.startScenario("test"), error);
assert.equal(server._state, "init");
} finally {
server._version = version;
server.enableLuaUdp = false;
}
});
it("should not have a host port when not running", function() {
assert.equal(server.hostUdpPort, undefined);
});
+2 -2
View File
@@ -21,9 +21,9 @@ const requireApi = [
"or package.loaded['__level__/modules/clusterio/api.lua']", // 2.0.0
].join(" ");
// --enable-lua-udp was added in Factorio 2.0.59
// Lua UDP needs Factorio 2.1.12, see docs/configuration.md
function hasLuaUdp() {
return lib.integerFullVersion(getFactorioVersion()) >= lib.integerFullVersion("2.0.59");
return lib.integerFullVersion(getFactorioVersion()) >= lib.integerFullVersion("2.1.12");
}
function getUser(name) {
+7 -4
View File
@@ -125,8 +125,8 @@ describe("Integration of host/src/server", function() {
let mapPath = server.writePath("saves", "test.zip");
await assert.doesNotReject(fs.access(mapPath), "save is missing");
// --enable-lua-udp was added in Factorio 2.0.59
server.enableLuaUdp = lib.integerFullVersion(server.version) >= lib.integerFullVersion("2.0.59");
// Lua UDP needs Factorio 2.1.12, see docs/configuration.md
server.enableLuaUdp = lib.integerFullVersion(server.version) >= lib.integerFullVersion("2.1.12");
await server.start("test.zip");
});
});
@@ -182,9 +182,11 @@ describe("Integration of host/src/server", function() {
}
log("Lua UDP to game");
// Poll from on_tick like the clusterio module does
await server.sendRcon(
"/sc script.on_event(defines.events.on_udp_packet_received, " +
"function(event) print('udp:' .. event.payload) end)"
"function(event) print('udp:' .. event.payload) end) " +
"script.on_nth_tick(1, function() helpers.recv_udp(0) end)"
);
let pass = false;
function filter(output) {
@@ -195,8 +197,9 @@ describe("Integration of host/src/server", function() {
server.on("output", filter);
await server.sendUdp("hello");
// The server does not tick without players, commands make it tick
for (let i = 0; i < 10; i++) {
await server.sendRcon("/sc helpers.recv_udp(0)");
await server.sendRcon("/sc rcon.print('tick')");
await lib.wait(10);
if (pass) {
break;