From 7d840faaccbf5e480458b0f6993c9bf2a5ece66a Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Tue, 4 Jun 2024 14:18:58 -0500 Subject: [PATCH] Make it safer --- src/state/persisted/store.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/state/persisted/store.ts b/src/state/persisted/store.ts index 93f05651c3..421bdccdf7 100644 --- a/src/state/persisted/store.ts +++ b/src/state/persisted/store.ts @@ -17,11 +17,13 @@ export async function read(): Promise { if (parsed.success) { return objData } else { - const errors = parsed.error.errors.map(e => ({ - code: e.code, - expected: e.expected, - path: e.path, - })) + const errors = + parsed.error?.errors?.map(e => ({ + code: e.code, + // @ts-ignore exists on some types + expected: e?.expected, + path: e.path, + })) || [] logger.error(`persisted store: data failed validation on read`, {errors}) return undefined }