diff --git a/src/server/Master.ts b/src/server/Master.ts index 5a1fe2778..f63edcc23 100644 --- a/src/server/Master.ts +++ b/src/server/Master.ts @@ -172,9 +172,12 @@ async function fetchLobbies(): Promise { const fetchPromises = []; for (const gameID of publicLobbyIDs) { + const controller = new AbortController(); + setTimeout(() => controller.abort(), 5000); // 5 second timeout const port = config.workerPort(gameID); const promise = fetch(`http://localhost:${port}/api/game/${gameID}`, { headers: { [config.adminHeader()]: config.adminToken() }, + signal: controller.signal, }) .then((resp) => resp.json()) .then((json) => { diff --git a/src/server/Worker.ts b/src/server/Worker.ts index 04180e072..b8ca5ff1d 100644 --- a/src/server/Worker.ts +++ b/src/server/Worker.ts @@ -187,7 +187,7 @@ export function startWorker() { const game = gm.game(req.params.id); if (game == null) { log.info(`lobby ${req.params.id} not found`); - return res.status(404); + return res.status(404).json({ error: "Game not found" }); } res.json(game.gameInfo()); }),