Revert "Close socket on ClientMessageSchema, improve zod error (#1003)"

This reverts commit 14ab1bcbba.
This commit is contained in:
Scott Anderson
2025-06-05 12:28:59 -04:00
committed by GitHub
parent bd820425ba
commit a6a8d2d0f2
2 changed files with 9 additions and 20 deletions
+3 -10
View File
@@ -10,8 +10,7 @@ import { GameEnv } from "../core/configuration/Config";
import { getServerConfigFromServer } from "../core/configuration/ConfigLoader";
import { GameType } from "../core/game/Game";
import {
ClientJoinMessageSchema,
GameConfig,
ClientMessageSchema,
GameRecord,
GameRecordSchema,
} from "../core/Schemas";
@@ -294,17 +293,11 @@ export function startWorker() {
: forwarded || req.socket.remoteAddress || "unknown";
try {
// Process WebSocket messages as in your original code
// Parse and handle client messages
const parsed = ClientJoinMessageSchema.safeParse(
const clientMsg = ClientMessageSchema.parse(
JSON.parse(message.toString()),
);
if (!parsed.success) {
const error = z.prettifyError(parsed.error);
log.warn("Error parsing join message client", error);
ws.close();
return;
}
const clientMsg = parsed.data;
if (clientMsg.type === "join") {
// Verify this worker should handle this game