From 319508c36084bbae85c4f66b4c24d4d746c047af Mon Sep 17 00:00:00 2001 From: evanpelle Date: Wed, 10 Sep 2025 07:36:42 -0700 Subject: [PATCH] bugfix: archive error, use replacer (#2041) ## Description: Use replacer when serializing GameRecord json ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: evan --- src/server/Archive.ts | 3 ++- src/server/Worker.ts | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/server/Archive.ts b/src/server/Archive.ts index 4361014fe..b540f9c8d 100644 --- a/src/server/Archive.ts +++ b/src/server/Archive.ts @@ -7,6 +7,7 @@ import { ID, PartialGameRecord, } from "../core/Schemas"; +import { replacer } from "../core/Util"; import { logger } from "./Logger"; const config = getServerConfigFromServer(); @@ -25,7 +26,7 @@ export async function archive(gameRecord: GameRecord) { const url = `${config.jwtIssuer()}/game/${gameRecord.info.gameID}`; const response = await fetch(url, { method: "POST", - body: JSON.stringify(gameRecord), + body: JSON.stringify(gameRecord, replacer), headers: { "Content-Type": "application/json", "x-api-key": config.apiKey(), diff --git a/src/server/Worker.ts b/src/server/Worker.ts index 54bf28cd3..8187ccbf2 100644 --- a/src/server/Worker.ts +++ b/src/server/Worker.ts @@ -16,6 +16,7 @@ import { PartialGameRecordSchema, ServerErrorMessage, } from "../core/Schemas"; +import { replacer } from "../core/Util"; import { CreateGameInputSchema, GameInputSchema } from "../core/WorkerSchemas"; import { archive, finalizeGameRecord, readGameRecord } from "./Archive"; import { Client } from "./Client"; @@ -340,7 +341,9 @@ export async function startWorker() { // Ignore ping return; } else if (clientMsg.type !== "join") { - log.warn(`Invalid message before join: ${JSON.stringify(clientMsg)}`); + log.warn( + `Invalid message before join: ${JSON.stringify(clientMsg, replacer)}`, + ); return; }