From bb6ce06e5a93354efdee2a6696d372564ee8abbf Mon Sep 17 00:00:00 2001 From: bbassie <17990055+bbassie@users.noreply.github.com> Date: Tue, 17 Nov 2026 16:05:57 +0000 Subject: [PATCH 1/2] Test only the oldest and latest supported Node.js in CI The middle version adds two jobs without catching anything the top and bottom of the range would miss. The host whitelist watcher now uses Set.difference, which every supported Node.js has. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/node.js.yml | 12 +++--------- packages/host/src/server.ts | 5 ++--- packages/lib/tsconfig.node.json | 2 ++ test/host/server.js | 22 ++++++++++++++++++++++ tsconfig.node.json | 2 +- 5 files changed, 30 insertions(+), 13 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index cb033ec7..77cdef07 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -29,9 +29,9 @@ jobs: fail-fast: false matrix: # To stay within the concurrent job limit, every Factorio version is - # tested on the latest Node.js, and every other supported Node.js - # version only with the latest Factorio. Coverage is performed on the - # oldest supported Node.js. + # tested on the latest Node.js, and the oldest supported Node.js only + # with the latest Factorio. Versions in between are not tested. + # Coverage is performed on the oldest supported Node.js. # Node.js release schedule: https://nodejs.org/en/about/releases/ # Supported factorio versions are latest stable and one minor version before stable (even if from a previous major) node-version: [26.x] @@ -42,12 +42,6 @@ jobs: tests: [ctl, other] include: - - node-version: 24.x - factorio-version: 2.1.17 - tests: ctl - - node-version: 24.x - factorio-version: 2.1.17 - tests: other - node-version: 22.x factorio-version: 2.1.17 tests: ctl diff --git a/packages/host/src/server.ts b/packages/host/src/server.ts index 1e1526a5..6bc02ba0 100644 --- a/packages/host/src/server.ts +++ b/packages/host/src/server.ts @@ -1155,9 +1155,8 @@ export class FactorioServer extends events.EventEmitter { } const newWhitelist = new Set(newWhitelistJson); - // Set.difference added in node v22 and so we can not use this due to v20 support - const added = newWhitelistJson.filter(e => !this._whitelist.has(e)); - const removed = [...this._whitelist.values()].filter(e => !newWhitelist.has(e)); + const added = [...newWhitelist.difference(this._whitelist)]; + const removed = [...this._whitelist.difference(newWhitelist)]; this._whitelist = newWhitelist; this.emit("whitelist-change", added, removed); diff --git a/packages/lib/tsconfig.node.json b/packages/lib/tsconfig.node.json index 983999cb..aa054f1c 100644 --- a/packages/lib/tsconfig.node.json +++ b/packages/lib/tsconfig.node.json @@ -4,5 +4,7 @@ "exclude": ["src/**/*.browser.ts"], "compilerOptions": { "allowJs": true, + // SubscriptionFilters.union clashes with the native Set.union + "lib": ["es2023"], }, } diff --git a/test/host/server.js b/test/host/server.js index 043aae0c..96ca5597 100644 --- a/test/host/server.js +++ b/test/host/server.js @@ -273,6 +273,28 @@ describe("host/server", function() { }); }); + describe("._watchWhitelist()", function() { + it("should emit the added and removed players on change", async function() { + const whitelistPath = path.join(writePath, "server-whitelist.json"); + await fs.mkdir(writePath, { recursive: true }); + await fs.writeFile(whitelistPath, JSON.stringify(["a", "b"])); + server.enableWhitelist = true; + server._whitelist = new Set(["a", "b"]); + server._watchWhitelist(); + try { + const waiter = events.once(server, "whitelist-change"); + await fs.writeFile(whitelistPath, JSON.stringify(["b", "c", "c"])); + const [added, removed] = await waiter; + assert.deepEqual(added, ["c"]); + assert.deepEqual(removed, ["a"]); + assert.deepEqual([...server._whitelist], ["b", "c"]); + } finally { + server._whitelistWatcher?.close(); + server.enableWhitelist = false; + } + }); + }); + describe(".fromOptions()", function() { it("should resolve the requested version", async function() { const found = await hostServer.FactorioServer.fromOptions( diff --git a/tsconfig.node.json b/tsconfig.node.json index d0941899..afebc425 100644 --- a/tsconfig.node.json +++ b/tsconfig.node.json @@ -1,7 +1,7 @@ { "extends": "./tsconfig.base.json", "compilerOptions": { - "lib": ["es2023"], + "lib": ["es2023", "es2025.collection"], "types": ["node"], "module": "nodenext", "moduleResolution": "node16", From 211180a801fb0e4dc9ec47dc5d4fb2450a631226 Mon Sep 17 00:00:00 2001 From: bbassie <17990055+bbassie@users.noreply.github.com> Date: Tue, 17 Nov 2026 16:13:55 +0000 Subject: [PATCH 2/2] Type check Node.js code against ES2024 Node.js 22 supports all of it. Co-Authored-By: Claude Opus 5.5 --- packages/lib/tsconfig.node.json | 2 +- tsconfig.node.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/lib/tsconfig.node.json b/packages/lib/tsconfig.node.json index aa054f1c..cd88dc5b 100644 --- a/packages/lib/tsconfig.node.json +++ b/packages/lib/tsconfig.node.json @@ -5,6 +5,6 @@ "compilerOptions": { "allowJs": true, // SubscriptionFilters.union clashes with the native Set.union - "lib": ["es2023"], + "lib": ["es2024"], }, } diff --git a/tsconfig.node.json b/tsconfig.node.json index afebc425..ef53e592 100644 --- a/tsconfig.node.json +++ b/tsconfig.node.json @@ -1,7 +1,7 @@ { "extends": "./tsconfig.base.json", "compilerOptions": { - "lib": ["es2023", "es2025.collection"], + "lib": ["es2024", "es2025.collection"], "types": ["node"], "module": "nodenext", "moduleResolution": "node16",