Invoke the config changed hook for every field

The fieldChanged handler repeated the hook invoke in each branch, and
factorio.shutdown_timeout had no invoke at all, so plugins were never
told about a change to it. Do the field specific side effect, then
invoke the hook once for every field.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
bbassieandClaude Opus 5 committed 2026-09-13 17:08:53 +00:00
1 parent 96362a2835
commit a76b742294
2 files changed
+32 -9

No files matched your search

+29
View File
@@ -128,6 +128,35 @@ describe("class Instance", function() {
instance.notifyStatus("stopped");
await wait(10);
});
it("should invoke the hook for fields applied to the server directly", async function() {
instance.config.set("factorio.shutdown_timeout", 30);
assert.equal(await hookInvoked, "factorio.shutdown_timeout");
assert.equal(instance.server.shutdownTimeoutMs, 30000);
await wait(10);
assert.deepEqual(errors, []);
assert.deepEqual(rejections, []);
});
it("should invoke the hook exactly once per field changed", async function() {
let invoked = [];
instance._host.whitelist = new Set();
instance.hooks.instanceConfigFieldChanged.attach("count", field => { invoked.push(field); });
instance.config.set("factorio.settings", { tags: ["a"] });
instance.config.set("factorio.enable_whitelist", true);
instance.config.set("factorio.shutdown_timeout", 30);
instance.config.set("factorio.max_concurrent_commands", 3);
await wait(10);
assert.deepEqual(invoked, [
"factorio.settings",
"factorio.enable_whitelist",
"factorio.shutdown_timeout",
"factorio.max_concurrent_commands",
]);
assert.equal(instance.server.maxConcurrentCommands, 3);
assert.deepEqual(errors, []);
assert.deepEqual(rejections, []);
});
});
describe("list update events", function() {