Merge remote-tracking branch 'origin/master' into host-pairing

# Conflicts:
#	packages/host/host.ts
This commit is contained in:
Danielv123 committed 2026-10-30 21:50:38 +01:00
commit 95422e6d21
21 files changed
+61 -27

No files matched your search

+23 -7
View File
@@ -28,17 +28,33 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
# Test Node.js 24 and 26 across the Factorio matrix; Node.js 22 runs coverage below. # 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.
# Node.js release schedule: https://nodejs.org/en/about/releases/ # Node.js release schedule: https://nodejs.org/en/about/releases/
node-version: [24.x, 26.x]
# Supported factorio versions are latest stable and one minor version before stable (even if from a previous major) # Supported factorio versions are latest stable and one minor version before stable (even if from a previous major)
node-version: [26.x]
factorio-version: [1.1.110, 2.0.77, 2.1.17] factorio-version: [1.1.110, 2.0.77, 2.1.17]
# Coverage is performed on the older of the supported node versions # The tests run in two halves of similar length on separate runners,
# the clusterioctl, plugin system and instance integration tests and the rest.
tests: [ctl, other]
include: 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 - node-version: 22.x
factorio-version: 2.1.17 factorio-version: 2.1.17
tests: ctl
coverage: true
- node-version: 22.x
factorio-version: 2.1.17
tests: other
coverage: true coverage: true
steps: steps:
@@ -51,10 +67,10 @@ jobs:
run: wget -q -O factorio.tar.gz https://www.factorio.com/get-download/${{ matrix.factorio-version }}/headless/linux64 && tar -xf factorio.tar.gz && rm factorio.tar.gz run: wget -q -O factorio.tar.gz https://www.factorio.com/get-download/${{ matrix.factorio-version }}/headless/linux64 && tar -xf factorio.tar.gz && rm factorio.tar.gz
- name: Run tests - name: Run tests
if: ${{ !matrix.coverage }} if: ${{ !matrix.coverage }}
run: pnpm test run: pnpm test --grep "^(Integration of Clusterio (clusterioctl|plugin system)|Clusterio Instance) " ${{ matrix.tests == 'other' && '--invert' || '' }}
- name: Run coverage - name: Run coverage
if: ${{ matrix.coverage }} if: ${{ matrix.coverage }}
run: pnpm run ci-cover run: pnpm run ci-cover --grep "^(Integration of Clusterio (clusterioctl|plugin system)|Clusterio Instance) " ${{ matrix.tests == 'other' && '--invert' || '' }}
- name: Upload coverage to Codecov - name: Upload coverage to Codecov
if: ${{ matrix.coverage }} if: ${{ matrix.coverage }}
uses: codecov/codecov-action@v7 uses: codecov/codecov-action@v7
@@ -67,7 +83,7 @@ jobs:
if: ${{ !cancelled() }} if: ${{ !cancelled() }}
uses: actions/upload-artifact@v7 uses: actions/upload-artifact@v7
with: with:
name: logs-${{ matrix.node-version }}-${{ matrix.factorio-version }} name: logs-${{ matrix.node-version }}-${{ matrix.factorio-version }}-${{ matrix.tests }}
path: temp/test/logs path: temp/test/logs
version-compat: version-compat:
+2 -1
View File
@@ -339,7 +339,8 @@ The format of this log should be self explanatory, please follow it carefully. P
For development, use the latest Node.js LTS release, following the [installation instructions](../README.md#installation). For development, use the latest Node.js LTS release, following the [installation instructions](../README.md#installation).
Make sure the Node.js built-in APIs and npm packages you use remain compatible with the supported versions. Make sure the Node.js built-in APIs and npm packages you use remain compatible with the supported versions.
The GitHub Actions tests currently run on Node.js 24 and 26 across the Factorio matrix, with Node.js 22 used for coverage; see the [CI workflow](../.github/workflows/node.js.yml) for the version matrix. The GitHub Actions tests run every Factorio version on the latest Node.js, and every other supported Node.js version with the latest Factorio only, which keeps the number of jobs within GitHub's concurrent job limit.
Coverage is collected on the oldest supported Node.js; see the [CI workflow](../.github/workflows/node.js.yml) for the version matrix.
For Factorio, active support covers the latest stable version and the previous major version, using version lines such as 2.1, 2.0 and 1.1 as described in the [Factorio support policy](decisions.md#factorio). For Factorio, active support covers the latest stable version and the previous major version, using version lines such as 2.1, 2.0 and 1.1 as described in the [Factorio support policy](decisions.md#factorio).
Older versions from 0.17 onwards receive passive support where it does not restrict actively supported versions. Older versions from 0.17 onwards receive passive support where it does not restrict actively supported versions.
+1 -1
View File
@@ -28,7 +28,7 @@
] ]
}, },
"engines": { "engines": {
"node": ">=22" "node": "^22.18.0 || >=24.2.0"
}, },
"workspaces": [ "workspaces": [
"packages/*", "packages/*",
+6 -1
View File
@@ -25,10 +25,12 @@ import DailyRotateFile from "winston-daily-rotate-file";
// homebrew modules // homebrew modules
// Reduce startup time by lazy compiling schemas.
import "./src/set_lazy_schema_compilation.js";
import * as lib from "@clusterio/lib"; import * as lib from "@clusterio/lib";
import { ConsoleTransport, levels, logger } from "@clusterio/lib"; import { ConsoleTransport, levels, logger } from "@clusterio/lib";
import Controller from "./src/Controller.js"; import type Controller from "./src/Controller.js";
import UserManager from "./src/UserManager.js"; import UserManager from "./src/UserManager.js";
import UserRecord from "./src/UserRecord.js"; import UserRecord from "./src/UserRecord.js";
import packageConfig from "@clusterio/controller/package.json" with { type: "json" }; import packageConfig from "@clusterio/controller/package.json" with { type: "json" };
@@ -194,6 +196,7 @@ async function handleBootstrapCommand(
} }
let ctlConfig = new lib.CtlConfig("control"); let ctlConfig = new lib.CtlConfig("control");
const { default: Controller } = await import("./src/Controller.js");
ctlConfig.set("ctl.controller_url", Controller.calculateControllerUrl(controllerConfig)); ctlConfig.set("ctl.controller_url", Controller.calculateControllerUrl(controllerConfig));
ctlConfig.set( ctlConfig.set(
"ctl.controller_token", "ctl.controller_token",
@@ -463,6 +466,8 @@ async function startup() {
return; return;
} }
// Loaded here as the server is not needed by the other commands
const { default: Controller } = await import("./src/Controller.js");
controller = await Controller.fromConfig( controller = await Controller.fromConfig(
controllerConfig, controllerConfig,
pluginInfos, pluginInfos,
+1 -1
View File
@@ -32,7 +32,7 @@
"clusteriocontroller": "./dist/node/controller.js" "clusteriocontroller": "./dist/node/controller.js"
}, },
"engines": { "engines": {
"node": ">=22" "node": "^22.18.0 || >=24.2.0"
}, },
"dependencies": { "dependencies": {
@@ -0,0 +1,3 @@
// This needs to be a separate file due to ECMAScript Modules evaluating code in
// imported modules before any code in the file that imports it.
(global as any).lazySchemaCompilation = true;
+1 -1
View File
@@ -28,7 +28,7 @@
"clusteriocreate": "./create.js" "clusteriocreate": "./create.js"
}, },
"engines": { "engines": {
"node": ">=22" "node": "^22.18.0 || >=24.2.0"
}, },
"dependencies": { "dependencies": {
+1 -1
View File
@@ -32,7 +32,7 @@
"clusterioctl": "./dist/node/ctl.js" "clusterioctl": "./dist/node/ctl.js"
}, },
"engines": { "engines": {
"node": ">=22" "node": "^22.18.0 || >=24.2.0"
}, },
"dependencies": { "dependencies": {
+5 -1
View File
@@ -20,10 +20,12 @@ import winston from "winston";
import "winston-daily-rotate-file"; import "winston-daily-rotate-file";
// internal libraries // internal libraries
// Reduce startup time by lazy compiling schemas.
import "./src/set_lazy_schema_compilation.js";
import * as lib from "@clusterio/lib"; import * as lib from "@clusterio/lib";
import { ConsoleTransport, levels, logger } from "@clusterio/lib"; import { ConsoleTransport, levels, logger } from "@clusterio/lib";
import Host from "./src/Host.js"; import type Host from "./src/Host.js";
import { createScenarioCommand, handleCreateScenarioCommand } from "./src/create_scenario.js"; import { createScenarioCommand, handleCreateScenarioCommand } from "./src/create_scenario.js";
import { PairingError, ensurePaired } from "./src/pairing.js"; import { PairingError, ensurePaired } from "./src/pairing.js";
@@ -254,6 +256,8 @@ async function startHost() {
} }
} }
// Loaded here as the server is not needed by the other commands
const { default: Host } = await import("./src/Host.js");
let hostConnector = new HostConnector(hostConfig, pluginInfos); let hostConnector = new HostConnector(hostConfig, pluginInfos);
host = await Host.fromConfig( host = await Host.fromConfig(
hostConfig, hostConfig,
+1 -1
View File
@@ -33,7 +33,7 @@
"clusteriohost": "./dist/node/host.js" "clusteriohost": "./dist/node/host.js"
}, },
"engines": { "engines": {
"node": ">=22" "node": "^22.18.0 || >=24.2.0"
}, },
"dependencies": { "dependencies": {
@@ -0,0 +1,3 @@
// This needs to be a separate file due to ECMAScript Modules evaluating code in
// imported modules before any code in the file that imports it.
(global as any).lazySchemaCompilation = true;
+1 -1
View File
@@ -46,7 +46,7 @@
"compile_validator": "node scripts/compile_validator.js" "compile_validator": "node scripts/compile_validator.js"
}, },
"engines": { "engines": {
"node": ">=22" "node": "^22.18.0 || >=24.2.0"
}, },
"dependencies": { "dependencies": {
+1 -1
View File
@@ -29,7 +29,7 @@
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"engines": { "engines": {
"node": ">=22" "node": "^22.18.0 || >=24.2.0"
}, },
"dependencies": { "dependencies": {
+1 -1
View File
@@ -30,7 +30,7 @@
"test": "echo \"Error: run tests from root\" && exit 1" "test": "echo \"Error: run tests from root\" && exit 1"
}, },
"engines": { "engines": {
"node": ">=22" "node": "^22.18.0 || >=24.2.0"
}, },
"peerDependencies": { "peerDependencies": {
+1 -1
View File
@@ -30,7 +30,7 @@
"test": "echo \"Error: run tests from root\" && exit 1" "test": "echo \"Error: run tests from root\" && exit 1"
}, },
"engines": { "engines": {
"node": ">=22" "node": "^22.18.0 || >=24.2.0"
}, },
"peerDependencies": { "peerDependencies": {
+1 -1
View File
@@ -30,7 +30,7 @@
"test": "echo \"Error: run tests from root\" && exit 1" "test": "echo \"Error: run tests from root\" && exit 1"
}, },
"engines": { "engines": {
"node": ">=22" "node": "^22.18.0 || >=24.2.0"
}, },
"peerDependencies": { "peerDependencies": {
+1 -1
View File
@@ -30,7 +30,7 @@
"test": "echo \"Error: run tests from root\" && exit 1" "test": "echo \"Error: run tests from root\" && exit 1"
}, },
"engines": { "engines": {
"node": ">=22" "node": "^22.18.0 || >=24.2.0"
}, },
"peerDependencies": { "peerDependencies": {
+1 -1
View File
@@ -30,7 +30,7 @@
"test": "echo \"Error: run tests from root\" && exit 1" "test": "echo \"Error: run tests from root\" && exit 1"
}, },
"engines": { "engines": {
"node": ">=22" "node": "^22.18.0 || >=24.2.0"
}, },
"peerDependencies": { "peerDependencies": {
+1 -1
View File
@@ -30,7 +30,7 @@
"test": "echo \"Error: run tests from root\" && exit 1" "test": "echo \"Error: run tests from root\" && exit 1"
}, },
"engines": { "engines": {
"node": ">=22" "node": "^22.18.0 || >=24.2.0"
}, },
"peerDependencies": { "peerDependencies": {
+3 -3
View File
@@ -217,17 +217,17 @@ export function exec(command, options = {}) {
} }
export function execController(...args) { export function execController(...args) {
args[0] = `node --enable-source-maps ../../packages/controller ${args[0]}`; args[0] = `node --enable-source-maps ../../packages/controller/dist/node/controller.js ${args[0]}`;
return exec(...args); return exec(...args);
} }
export function execHost(...args) { export function execHost(...args) {
args[0] = `node --enable-source-maps ../../packages/host ${args[0]}`; args[0] = `node --enable-source-maps ../../packages/host/dist/node/host.js ${args[0]}`;
return exec(...args); return exec(...args);
} }
export function execCtlProcess(...args) { export function execCtlProcess(...args) {
args[0] = `node --enable-source-maps ../../packages/ctl ${args[0]}`; args[0] = `node --enable-source-maps ../../packages/ctl/dist/node/ctl.js ${args[0]}`;
return exec(...args); return exec(...args);
} }
+3 -1
View File
@@ -169,7 +169,9 @@ describe("Integration of lib/link", function() {
it("should close old connections from the same address", async function() { it("should close old connections from the same address", async function() {
slowTest(this); slowTest(this);
const hostConnectorFirst = new TestHostConnector(url, 0.2); // Without a link the disconnect prepare goes unanswered and the controller waits 10 s for it
const hostLinkFirst = new lib.Link(new TestHostConnector(url, 0.2));
const hostConnectorFirst = hostLinkFirst.connector;
hostConnectorFirst.token = hostConnector.token; hostConnectorFirst.token = hostConnector.token;
hostConnectorFirst.hostId = hostConnector.hostId; hostConnectorFirst.hostId = hostConnector.hostId;
const onceClose = events.once(hostConnectorFirst, "close"); const onceClose = events.once(hostConnectorFirst, "close");