fix(monitor): use global console channel and implement shard filtering
Lint / pre-commit Linting (push) Successful in 44s
Test / Run Tests (push) Successful in 1m4s

This commit is contained in:
2026-05-16 20:26:32 +02:00
parent 6384addc42
commit d02f44f6c7
4 changed files with 39 additions and 16 deletions
+11 -3
View File
@@ -29,8 +29,9 @@ export function isOfficialServer(hostname) {
* @returns {string}
*/
export function buildSubscribePath(hostname, shard) {
if (shard) return `${shard}/console`;
return isOfficialServer(hostname) ? "shard0/console" : "console";
// The console channel on Screeps official and most private servers is 'console'.
// We subscribe to the aggregate feed and filter by shard in handleConsoleEvent.
return "console";
}
/**
@@ -178,8 +179,15 @@ export async function uploadLogArtifact(
* @param {{ sawTraceback: boolean, sawErrorLog: boolean, sawWarningLog: boolean }} state
*/
export function handleConsoleEvent(event, opts, stdoutBuffer, state) {
const { logToFile } = opts;
const { logToFile, shard: targetShard } = opts;
const data = event?.data ?? {};
// Shard filtering: If a shard is specified in opts, only process messages from that shard.
// Official server events include a 'shard' property in event.data.
if (targetShard && data.shard && data.shard !== targetShard) {
return;
}
const logLines = data?.messages?.log ?? [];
const results = data?.messages?.results ?? [];
const errorText = data?.error ?? null;