mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-16 23:30:41 +09:00
Log errors from instance config change handlers
The fieldChanged handler in the Instance constructor ran updateFactorioSettings and updateFactorioWhitelist with only a finally attached. A rejection from either went unhandled, and the host exits on unhandled rejections, taking every instance on it down. Two ways to hit it against a real host: - Start an instance and immediately toggle factorio.enable_whitelist. updateFactorioWhitelist calls sendRcon while the server state is still "new" and it throws "Expected state running,stopping but state is new". - Set factorio.settings tags to [1] on a running instance. applyAsConfig called tag.replace outside its try block and threw "tag.replace is not a function". Catch and log both on the instance logger before invoking the hook, and convert tags with String() so non-string entries no longer throw. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
f4aa894fe7
commit
18aed41889
2 files changed
+58
-4
No files matched your search
@@ -61,7 +61,7 @@ function applyAsConfig(name: string) {
|
||||
// Replace spaces with non-break spaces and delimit by spaces.
|
||||
// This does change the defined tags, but there doesn't seem to
|
||||
// be a way to include a space into a tag from the console.
|
||||
value = value.map(tag => tag.replace(/ /g, "\u00a0")).join(" ");
|
||||
value = value.map(tag => String(tag).replace(/ /g, "\u00a0")).join(" ");
|
||||
}
|
||||
try {
|
||||
await instance.sendRcon(`/config set ${name} ${value}`);
|
||||
@@ -199,9 +199,13 @@ export default class Instance extends lib.Link {
|
||||
if (field === "factorio.shutdown_timeout") {
|
||||
this.server.shutdownTimeoutMs = curr as number * 1000;
|
||||
} else if (field === "factorio.settings") {
|
||||
this.updateFactorioSettings(curr as any, prev as any).finally(hook);
|
||||
this.updateFactorioSettings(curr as any, prev as any).catch(err => {
|
||||
this.logger.error(`Error updating server settings:\n${err.stack}`);
|
||||
}).finally(hook);
|
||||
} else if (field === "factorio.enable_whitelist") {
|
||||
this.updateFactorioWhitelist(curr as any).finally(hook);
|
||||
this.updateFactorioWhitelist(curr as any).catch(err => {
|
||||
this.logger.error(`Error updating whitelist:\n${err.stack}`);
|
||||
}).finally(hook);
|
||||
} else {
|
||||
if (field === "factorio.max_concurrent_commands") {
|
||||
this.server.maxConcurrentCommands = curr as number;
|
||||
|
||||
Reference in new issue
Block a user