diff --git a/packages/api/src/utils/client/client.ts b/packages/api/src/utils/client/client.ts index 0a8cd95204b1..44c87c4dbbd9 100644 --- a/packages/api/src/utils/client/client.ts +++ b/packages/api/src/utils/client/client.ts @@ -1,8 +1,9 @@ -import {mapValues} from "@lodestar/utils"; +import {TimeoutError, mapValues} from "@lodestar/utils"; import {compileRouteUrlFormater} from "../urlFormat.js"; import {RouteDef, ReqGeneric, ReturnTypes, TypeJson, ReqSerializer, ReqSerializers, RoutesData} from "../types.js"; import {APIClientHandler} from "../../interfaces.js"; import {FetchOpts, HttpError, IHttpClient} from "./httpClient.js"; +import {HttpStatusCode} from "./httpStatusCode.js"; // See /packages/api/src/routes/index.ts for reasoning @@ -83,6 +84,13 @@ export function generateGenericJsonClient< >; } + if (err instanceof TimeoutError) { + return { + ok: false, + error: {code: HttpStatusCode.INTERNAL_SERVER_ERROR, message: err.message, operationId: routeId}, + } as ReturnType; + } + throw err; } };