fix : AbortError logs

This commit is contained in:
GuillaumeSD
2024-12-29 18:15:05 +01:00
parent 4f8b0e2de6
commit a2a1c826b9

View File

@@ -14,7 +14,7 @@ export const getLichessEval = async (
): Promise<PositionEval> => { ): Promise<PositionEval> => {
try { try {
const controller = new AbortController(); const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 200); const timeoutId = setTimeout(() => controller.abort("timeout"), 200);
const res = await fetch( const res = await fetch(
`https://lichess.org/api/cloud-eval?fen=${fen}&multiPv=${multiPv}`, `https://lichess.org/api/cloud-eval?fen=${fen}&multiPv=${multiPv}`,
{ method: "GET", signal: controller.signal } { method: "GET", signal: controller.signal }
@@ -52,9 +52,14 @@ export const getLichessEval = async (
bestMove, bestMove,
lines: linesToKeep, lines: linesToKeep,
}; };
} catch (error) { } catch (rawError) {
const err = error instanceof Error ? error : new Error("Unknown error"); const error =
logErrorToSentry(err, { fen, multiPv }); rawError instanceof Error ? rawError : new Error("Unknown error");
if (error.name !== "AbortError") {
logErrorToSentry(error, { fen, multiPv });
}
return { return {
bestMove: "", bestMove: "",
lines: [], lines: [],