From d290054e5cf74269be496a2581498c2dca7014a6 Mon Sep 17 00:00:00 2001 From: evanpelle Date: Mon, 9 Dec 2024 13:14:59 -0800 Subject: [PATCH] catch and log archive failure to prevent server crash --- src/server/Archive.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/server/Archive.ts b/src/server/Archive.ts index d12b4bc53..9d5c78eea 100644 --- a/src/server/Archive.ts +++ b/src/server/Archive.ts @@ -4,10 +4,14 @@ import { Storage } from '@google-cloud/storage'; const storage = new Storage(); export async function archive(gameRecord: GameRecord) { - console.log(`writing game ${gameRecord.id} to gcs`) - const bucket = storage.bucket("openfront-games"); - const file = bucket.file(gameRecord.id); - await file.save(JSON.stringify(GameRecordSchema.parse(gameRecord)), { - contentType: 'application/json' - }); + try { + console.log(`writing game ${gameRecord.id} to gcs`) + const bucket = storage.bucket("openfront-games"); + const file = bucket.file(gameRecord.id); + await file.save(JSON.stringify(GameRecordSchema.parse(gameRecord)), { + contentType: 'application/json' + }); + } catch (error) { + console.log(`error writing to gcs: ${error}`) + } } \ No newline at end of file