From be4456825c91c79b482e2069d866cdd8ab928ea4 Mon Sep 17 00:00:00 2001 From: GuillaumeSD Date: Mon, 30 Dec 2024 00:22:34 +0100 Subject: [PATCH] fix : log lichess error --- src/lib/lichess.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/lichess.ts b/src/lib/lichess.ts index f832f3d..babeb8d 100644 --- a/src/lib/lichess.ts +++ b/src/lib/lichess.ts @@ -53,7 +53,7 @@ export const getLichessEval = async ( lines: linesToKeep, }; } catch (error) { - if (error !== "timeout") { + if (!isAbortError(error)) { logErrorToSentry(error, { fen, multiPv }); } @@ -64,6 +64,11 @@ export const getLichessEval = async ( } }; +const isAbortError = (error: unknown): boolean => + error === "timeout" || + ((error instanceof Error || error instanceof DOMException) && + (error.name === "AbortError" || error.message === "timeout")); + export const getLichessUserRecentGames = async ( username: string ): Promise => {